From 6241d71f47640de8f04ca9b3c97ac911d7a1e221 Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Wed, 14 Feb 2024 23:18:46 +0100 Subject: [PATCH] Rename the previous version of the database instead of copying it, since we're about to overwrite it anyway. --- src/schema/resource_list.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schema/resource_list.rs b/src/schema/resource_list.rs index 8968f91..5cab981 100644 --- a/src/schema/resource_list.rs +++ b/src/schema/resource_list.rs @@ -50,7 +50,7 @@ impl ResourceList { pub fn save(&self, path: impl AsRef + 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)