From dad84168ea515f1ed1752859d7fb1b222f25cc56 Mon Sep 17 00:00:00 2001 From: kieran Date: Wed, 1 May 2024 22:02:00 +0100 Subject: [PATCH] fix: Copy files instead of move --- src/filesystem.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/filesystem.rs b/src/filesystem.rs index 9547d71..26c8b21 100644 --- a/src/filesystem.rs +++ b/src/filesystem.rs @@ -54,10 +54,11 @@ impl FileStore { let hash = FileStore::hash_file(&mut file).await?; let dst_path = self.map_path(&hash); fs::create_dir_all(dst_path.parent().unwrap())?; - if let Err(e) = fs::rename(&tmp_path, &dst_path) { + if let Err(e) = fs::copy(&tmp_path, &dst_path) { fs::remove_file(&tmp_path)?; Err(Error::from(e)) } else { + fs::remove_file(tmp_path)?; Ok(FileSystemResult { size: n, sha256: hash,