diff options
| author | David Lönnhager <david.l@mullvad.net> | 2022-02-16 15:08:19 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2022-02-18 09:44:02 +0100 |
| commit | 457aec5d1cbde02ea7df51d3a79ae56e51b982df (patch) | |
| tree | e91aa0b5a46e2928fe931e47332037aa1438909e | |
| parent | 3a28f409df24d59d77ef2f3f1f98bf98c2c2ca7e (diff) | |
| download | mullvadvpn-457aec5d1cbde02ea7df51d3a79ae56e51b982df.tar.xz mullvadvpn-457aec5d1cbde02ea7df51d3a79ae56e51b982df.zip | |
Ensure file buffer is flushed after migrating settings
| -rw-r--r-- | mullvad-daemon/src/migrations/mod.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/mullvad-daemon/src/migrations/mod.rs b/mullvad-daemon/src/migrations/mod.rs index bb2d7fe3ea..73dc0f857b 100644 --- a/mullvad-daemon/src/migrations/mod.rs +++ b/mullvad-daemon/src/migrations/mod.rs @@ -62,9 +62,15 @@ pub enum Error { #[error(display = "Unable to serialize settings to JSON")] SerializeError(#[error(source)] serde_json::Error), + #[error(display = "Unable to open settings for writing")] + OpenError(#[error(source)] io::Error), + #[error(display = "Unable to write new settings")] WriteError(#[error(source)] io::Error), + #[error(display = "Unable to sync settings to disk")] + SyncError(#[error(source)] io::Error), + #[error(display = "Failed to read the account history")] ReadHistoryError(#[error(source)] io::Error), @@ -124,10 +130,11 @@ pub async fn migrate_all(cache_dir: &Path, settings_dir: &Path) -> Result<()> { .truncate(true) .open(&path) .await - .map_err(Error::WriteError)?; + .map_err(Error::OpenError)?; file.write_all(&buffer.into_bytes()) .await .map_err(Error::WriteError)?; + file.sync_data().await.map_err(Error::SyncError)?; Ok(()) } |
