Skip to content

Commit 3d272d7

Browse files
committed
refactor: 换用temp-dir管理临时文件夹
1 parent 0659dcf commit 3d272d7

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src-tauri/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ tauri-plugin-dialog = "2"
3838
specta = "=2.0.0-rc.20"
3939
specta-typescript = "0.0.7"
4040
tauri-specta = { version = "=2.0.0-rc.20", features = ["derive", "typescript"] }
41+
temp-dir = "0.1.14"
4142

4243
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
4344
tauri-plugin-global-shortcut = "2"

src-tauri/src/backup/archive.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ pub fn decompress_from_file(
131131
let file = File::open(zip_path).map_err(|e| CompressError::Single(e.into()))?;
132132
let mut zip = zip::ZipArchive::new(file).map_err(|e| CompressError::Single(e.into()))?;
133133

134-
let tmp_folder = PathBuf::from("./tmp"); //TODO: tmp dir
134+
let tmp_folder = temp_dir::TempDir::new().map_err(|e| CompressError::Single(e.into()))?; // Temporary directory for extraction
135+
let tmp_folder = tmp_folder.path().to_path_buf(); // Convert to PathBuf for easier manipulation
135136
fs::create_dir_all(&tmp_folder).map_err(|e| CompressError::Single(e.into()))?;
136137
zip.extract(&tmp_folder)
137138
.map_err(|e| CompressError::Single(e.into()))?;

0 commit comments

Comments
 (0)