Skip to content

Commit

Permalink
use built in remove dir command
Browse files Browse the repository at this point in the history
  • Loading branch information
guenhter committed Sep 14, 2024
1 parent fb89b1e commit 3c39fde
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 75 deletions.
122 changes: 69 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
description = "Small folder mirror tool for Windows using robocopy under the hood"
name = "simple-folder-syncer"
version = "0.1.0"
version = "0.1.1"
authors = ["Günther Grill <[email protected]>"]
license = "MIT"
repository = "https://github.com/guenhter/robocopy-folder-mirror"
Expand All @@ -22,7 +22,6 @@ walkdir = "2.5.0"
windows-sys = { version = "0.52.0", features = [
"Win32_System_Threading",
"Win32_Storage_FileSystem",

"Wdk_Foundation",
"Wdk_Storage_FileSystem",
"Win32_Foundation",
Expand Down
2 changes: 1 addition & 1 deletion package.wxs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="Simple Folder Syncer" Manufacturer="Grill Günther" UpgradeCode="9e914e0d-014b-4a92-a147-755ad34dfc26" Version="0.1">
<Package Name="Simple Folder Syncer" Manufacturer="Grill Günther" UpgradeCode="9e914e0d-014b-4a92-a147-755ad34dfc26" Version="0.1.1">
<Icon Id="icon.ico" SourceFile="resources\icon.ico"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<Property Id="ARPNOMODIFY" Value="no" Secure="yes" />
Expand Down
20 changes: 1 addition & 19 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn remove_excluded_files_and_folders_in_target(
for entry in folders_to_delete {
println!(" -- Removing {}", entry.display());

match remove_dir_all_alternative(entry) {
match fs::remove_dir_all(entry) {
Ok(_) => {}
Err(e) => {
println!("Error deleting folder {}", entry.display());
Expand Down Expand Up @@ -230,24 +230,6 @@ fn replace_root_path(
.collect()
}

// https://github.com/rust-lang/rust/issues/126576
// https://github.com/winfsp/winfsp/issues/561
fn remove_dir_all_alternative(path: &Path) -> anyhow::Result<()> {
for entry in fs::read_dir(path)? {
let path = entry?.path();

if path.is_dir() {
remove_dir_all_alternative(&path)?;
} else {
fs::remove_file(path)?;
}
}

fs::remove_dir(path)?;

Ok(())
}

#[cfg(test)]
mod tests {
use std::ffi::CString;
Expand Down

0 comments on commit 3c39fde

Please sign in to comment.