diff options
author | euxane | 2024-10-04 23:42:32 +0200 |
---|---|---|
committer | euxane | 2024-10-04 23:42:32 +0200 |
commit | 460a8c2430ff9c6fc4eda152f9f28044e244348b (patch) | |
tree | 46597fb604a3389d60f72cee335ccb00c32a974a /app/src/main/java | |
parent | e867668b1b9fdf96928b7f0c3d757219c757b52f (diff) | |
download | tincapp-460a8c2430ff9c6fc4eda152f9f28044e244348b.tar.gz |
config: restrict automatic storage migration to networks subdir
Avoiding aborting automatic migration when other system files are
already present at the root app files target directory (such as
"profileInstalled" or "rList".
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/context/StorageMigrator.kt | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/context/StorageMigrator.kt b/app/src/main/java/org/pacien/tincapp/context/StorageMigrator.kt index 6bde2f6..b920522 100644 --- a/app/src/main/java/org/pacien/tincapp/context/StorageMigrator.kt +++ b/app/src/main/java/org/pacien/tincapp/context/StorageMigrator.kt | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Tinc Mesh VPN: Android client and user interface | 2 | * Tinc Mesh VPN: Android client and user interface |
3 | * Copyright (C) 2017-2023 Euxane P. TRAN-GIRARD | 3 | * Copyright (C) 2017-2024 Euxane P. TRAN-GIRARD |
4 | * | 4 | * |
5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
@@ -40,11 +40,12 @@ class StorageMigrator { | |||
40 | } | 40 | } |
41 | 41 | ||
42 | private fun migrateConfigurationDirectory() { | 42 | private fun migrateConfigurationDirectory() { |
43 | val oldConfigDir = context.getExternalFilesDir(null) | 43 | val externalStorageDir = context.getExternalFilesDir(null) ?: return |
44 | if (oldConfigDir == null || oldConfigDir.listFiles().isNullOrEmpty()) return // nothing to do | 44 | val oldConfigDir = File(externalStorageDir, "networks") |
45 | if (!oldConfigDir.exists()) return | ||
45 | 46 | ||
46 | try { | 47 | try { |
47 | val newConfigDir = context.filesDir | 48 | val newConfigDir = AppPaths.confDir() |
48 | log.info( | 49 | log.info( |
49 | "Migrating files present in old configuration directory at {} to {}", | 50 | "Migrating files present in old configuration directory at {} to {}", |
50 | oldConfigDir.absolutePath, | 51 | oldConfigDir.absolutePath, |