From 18a20f957c6cb827a6d6562cdae4c48210e88f22 Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Fri, 31 Mar 2023 20:15:44 +0200 Subject: [PATCH] Migrate old source path as well. --- src/pages/content/settings.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/pages/content/settings.php b/src/pages/content/settings.php index 4449a3a..4ea828f 100644 --- a/src/pages/content/settings.php +++ b/src/pages/content/settings.php @@ -26,7 +26,11 @@ } if (isset($_POST['migrateConfig'])) { - $abSettings = json_decode(file_get_contents(ABSettings::getConfigPath()), true); + $abSettings = null; + if (file_exists(ABSettings::getConfigPath())) { + $abSettings = json_decode(file_get_contents(ABSettings::getConfigPath()), true); + } + if (empty($abSettings)) { $abSettings = []; } @@ -35,6 +39,16 @@ if (!empty($oldConfig['destinationShare'])) { $abSettings['destination'] = $oldConfig['destinationShare']; } + + $abSettings['allowedSources'] = ['/mnt/user/appdata', '/mnt/cache/appdata']; + + if (!empty($oldConfig['source'])) { + if (!in_array(rtrim($oldConfig['source'], '/'), $abSettings['allowedSources'])) { + $abSettings['allowedSources'][] = rtrim($oldConfig['source'], '/'); + } + $abSettings['allowedSources'] = implode("\r\n", $abSettings['allowedSources']); // Hackety hack! 😅 + } + if (!empty($oldConfig['compression'])) { $abSettings['compression'] = $oldConfig['compression'] == 'yes' ? 'yes' : 'no'; }