mirror of
https://github.com/darakian/ddh.git
synced 2026-09-10 07:06:21 -04:00
Canonicalize after getting metadata. Canonicalizing follows symlinks
This commit is contained in:
parent
6fe847896e
commit
0d525abd56
23
src/lib.rs
23
src/lib.rs
|
|
@ -54,6 +54,15 @@ pub fn deduplicate_dirs<P: AsRef<Path> + Sync>(search_dirs: Vec<P>) -> (Vec<File
|
|||
}
|
||||
|
||||
fn traverse_and_spawn(current_path: impl AsRef<Path>, sender: Sender<ChannelPackage>) -> (){
|
||||
let current_path_metadata = match fs::symlink_metadata(¤t_path) {
|
||||
Err(e) =>{
|
||||
sender.send(
|
||||
ChannelPackage::Fail(current_path.as_ref().to_path_buf(), e)
|
||||
).expect("Error sending new ChannelPackage::Fail");
|
||||
return
|
||||
},
|
||||
Ok(meta) => meta,
|
||||
};
|
||||
let current_path = match fs::canonicalize(¤t_path) {
|
||||
Err(e) => {
|
||||
sender.send(
|
||||
|
|
@ -61,17 +70,11 @@ fn traverse_and_spawn(current_path: impl AsRef<Path>, sender: Sender<ChannelPack
|
|||
).expect("Error sending new ChannelPackage::Fail");
|
||||
return
|
||||
},
|
||||
Ok(can_path) => can_path,
|
||||
};
|
||||
let current_path_metadata = match fs::symlink_metadata(¤t_path) {
|
||||
Err(e) =>{
|
||||
sender.send(
|
||||
ChannelPackage::Fail(current_path.to_path_buf(), e)
|
||||
).expect("Error sending new ChannelPackage::Fail");
|
||||
return
|
||||
},
|
||||
Ok(meta) => meta,
|
||||
Ok(canonical_path) => canonical_path,
|
||||
};
|
||||
if !current_path_metadata.file_type().is_file() && !current_path_metadata.file_type().is_dir(){
|
||||
println!("Operating on \n{:?}\n{:?}", current_path, current_path_metadata);
|
||||
}
|
||||
if current_path_metadata.file_type().is_symlink(){
|
||||
sender.send(
|
||||
ChannelPackage::Fail(current_path.to_path_buf(), Error::new(ErrorKind::Other, "Path is symlink"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue