From d572986594e9db525baed60b5c2d2717775e3b45 Mon Sep 17 00:00:00 2001 From: 8LWXpg <105704427+8LWXpg@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:11:25 +0800 Subject: [PATCH] fix folder rename --- CHANGELOG.md | 6 ++++++ src/util.rs | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7c35a9..564be91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## [0.4.2] + +### Fixed + +- Fixed extracting plugin with different folder name. + ## [0.4.1] ### Fixed diff --git a/src/util.rs b/src/util.rs index 9c9945d..39edc13 100644 --- a/src/util.rs +++ b/src/util.rs @@ -118,11 +118,13 @@ fn extract_zip(zip_path: &Path, output_dir: &Path, root_name: &str) -> Result<() } } - let extracted_root = output_dir.join(archive.by_index(0)?.name()); + let extracted_root = output_dir.join(archive.by_index(0)?.name().split('/').next().unwrap()); let root_path = output_dir.join(root_name); if extracted_root != root_path { // extracting to a different directory means we're not done polling for file access during extracting. - polling::remove_dir_all(&root_path)?; + if root_path.exists() { + polling::remove_dir_all(&root_path)?; + } fs::rename(extracted_root, &root_path)?; }