Rename the previous version of the database instead of copying it, since we're about to overwrite it anyway.

This commit is contained in:
Karcsesz 2024-02-14 23:18:46 +01:00
parent 0bae05342f
commit 6241d71f47

View file

@ -50,7 +50,7 @@ impl ResourceList {
pub fn save(&self, path: impl AsRef<Path> + Debug) -> Result<(), ResourceSaveError> {
info!("Creating backup before writing...");
let path = path.as_ref();
std::fs::copy(path, path.with_extension("bak")).map_err(ResourceSaveError::BackupFailed)?;
std::fs::rename(path, path.with_extension("bak")).map_err(ResourceSaveError::BackupFailed)?;
info!("Writing data to {path:?}...");
let file = std::fs::File::create(path).map_err(ResourceSaveError::FileOpen)?;
self.save_to_writer(file)