Skip to content

Commit

Permalink
Migrate old source path as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
Commifreak committed Mar 31, 2023
1 parent a3dfca1 commit 18a20f9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/pages/content/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
Expand All @@ -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';
}
Expand Down

0 comments on commit 18a20f9

Please sign in to comment.