Fix incomplete overwriting behaviour in fs.writeFile.

This contains the same fix as https://github.com/tauri-apps/tauri/pull/7982
which fixes https://github.com/tauri-apps/tauri/issues/7973
But as v2 moves things around a little bit the fix is necessary here as well.
pull/642/head
Ziyang Hu 2 years ago
parent 8902fe9adf
commit 32d8077dd4

@ -117,9 +117,9 @@ pub fn write_file<R: Runtime>(
.with_context(|| format!("path: {}", resolved_path.display()))
.map_err(Into::into)
.and_then(|mut f| {
f.write_all(&contents)
.map_err(|err| anyhow::anyhow!("{}", err))
.map_err(Into::into)
f.write_all(&contents).map_err(|err| anyhow::anyhow!("{}", err))?;
f.set_len(contents.len() as u64).map_err(|err| anyhow::anyhow!("{}", err))?;
Ok(())
})
}

Loading…
Cancel
Save