Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: add backup mechanism for existing plugin files during installation

Tonho97649972ef46
diff --git a/src-tauri/src/commands/plugins.rs b/src-tauri/src/commands/plugins.rs
index 77581062..33b6b5a1 100644
--- a/src-tauri/src/commands/plugins.rs
+++ b/src-tauri/src/commands/plugins.rs
@@ -341,6 +341,11 @@ pub async fn install_plugin_from_registry(
if let Some(parent) = outpath.parent() {
std::fs::create_dir_all(parent).map_err(|e| e.to_string())?;
}
+ if outpath.exists() {
+ let old = outpath.with_extension("old");
+ let _ = std::fs::remove_file(&old);
+ let _ = std::fs::rename(&outpath, &old);
+ }
let mut outfile = std::fs::File::create(&outpath).map_err(|e| e.to_string())?;
std::io::copy(&mut file, &mut outfile).map_err(|e| e.to_string())?;
}