diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-06-10 14:50:56 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-06-10 14:50:56 +0200 |
| commit | 71a7b7abf7ec3584e41c251bc7d22c61850a47af (patch) | |
| tree | 97b42ec688e212babd9f50ad454fae3f16ad1d91 | |
| parent | f9d364431c866118a18b06454bfada3a3a655815 (diff) | |
| parent | 204e03e8645b2cb6ad15bbbb8cb880c22b79c076 (diff) | |
| download | mullvadvpn-71a7b7abf7ec3584e41c251bc7d22c61850a47af.tar.xz mullvadvpn-71a7b7abf7ec3584e41c251bc7d22c61850a47af.zip | |
Merge branch 'fix-app-history-migration'
| -rw-r--r-- | mullvad-daemon/src/account_history.rs | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/mullvad-daemon/src/account_history.rs b/mullvad-daemon/src/account_history.rs index 1bd74a052a..23dd85a487 100644 --- a/mullvad-daemon/src/account_history.rs +++ b/mullvad-daemon/src/account_history.rs @@ -105,27 +105,18 @@ impl AccountHistory { fn migrate_from_old_file_location(old_dir: &Path, new_dir: &Path) { let old_path = old_dir.join(ACCOUNT_HISTORY_FILE); + let new_path = new_dir.join(ACCOUNT_HISTORY_FILE); + if !old_path.exists() || new_path.exists() || new_path == old_path { + return; + } - if old_path.exists() { - let new_path = new_dir.join(ACCOUNT_HISTORY_FILE); - - if new_path.exists() { - if let Err(error) = fs::remove_file(old_path) { - log::warn!( - "{}", - error.display_chain_with_msg("Failed to remove old account history file") - ); - } - } else { - if let Err(error) = fs::rename(old_path, new_path) { - log::error!( - "{}", - error.display_chain_with_msg( - "Failed to migrate account history file location" - ) - ); - } - } + if let Err(error) = fs::copy(&old_path, &new_path) { + log::error!( + "{}", + error.display_chain_with_msg("Failed to migrate account history file location") + ); + } else { + let _ = fs::remove_file(old_path); } } |
