fix: skip empty dir removal on single files and skip if dir is not empty
This commit is contained in:
+7
-1
@@ -10,6 +10,7 @@ pub fn move_files(
|
||||
tag: Tag,
|
||||
extra_files: [String; 8],
|
||||
should_copy: bool,
|
||||
has_parent: bool,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let target_dir = PathBuf::from("/home/user/Desktop/coding/keks-sort");
|
||||
|
||||
@@ -65,7 +66,12 @@ pub fn move_files(
|
||||
}
|
||||
}
|
||||
}
|
||||
remove_dir(file_path.parent().unwrap())?;
|
||||
|
||||
let is_empty = file_path.parent().unwrap().read_dir()?.next().is_none();
|
||||
if has_parent && is_empty {
|
||||
remove_dir(file_path.parent().unwrap())?;
|
||||
}
|
||||
|
||||
println!("Imported file: {:?}", file_path.file_name().unwrap());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user