From 460a8c2430ff9c6fc4eda152f9f28044e244348b Mon Sep 17 00:00:00 2001 From: euxane Date: Fri, 4 Oct 2024 23:42:32 +0200 Subject: 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". --- app/src/main/java/org/pacien/tincapp/context/StorageMigrator.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'app/src') 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 @@ /* * Tinc Mesh VPN: Android client and user interface - * Copyright (C) 2017-2023 Euxane P. TRAN-GIRARD + * Copyright (C) 2017-2024 Euxane P. TRAN-GIRARD * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,11 +40,12 @@ class StorageMigrator { } private fun migrateConfigurationDirectory() { - val oldConfigDir = context.getExternalFilesDir(null) - if (oldConfigDir == null || oldConfigDir.listFiles().isNullOrEmpty()) return // nothing to do + val externalStorageDir = context.getExternalFilesDir(null) ?: return + val oldConfigDir = File(externalStorageDir, "networks") + if (!oldConfigDir.exists()) return try { - val newConfigDir = context.filesDir + val newConfigDir = AppPaths.confDir() log.info( "Migrating files present in old configuration directory at {} to {}", oldConfigDir.absolutePath, -- cgit v1.2.3