Add test for extracting symlink nodes and fix behavior
This commit is contained in:
parent
b534cf6d49
commit
0ef17ca2ec
16
src/node.rs
16
src/node.rs
@ -286,7 +286,10 @@ impl Node {
|
||||
fs::hard_link(target, &path)?;
|
||||
}
|
||||
FileType::SoftLink(ref t) => {
|
||||
symlink(&self.name, t)?;
|
||||
if n_path.exists() {
|
||||
fs::remove_file(&n_path)?;
|
||||
}
|
||||
symlink(t, &n_path)?;
|
||||
}
|
||||
FileType::Directory => {
|
||||
self.mkdir(&PathBuf::from(&path))?;
|
||||
@ -528,4 +531,15 @@ mod tests {
|
||||
let f = fs::read_to_string("test/output/test/li.txt").unwrap();
|
||||
assert_eq!(f.as_bytes(), LI);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extract_symlink() {
|
||||
let links = Mutex::new(HashMap::new());
|
||||
let _res = remove_file("test/lilnk.txt");
|
||||
symlink("li.txt", "test/lilnk.txt").unwrap();
|
||||
let node = Node::from_path("test/lilnk.txt", Algorithm::Md5, &links).unwrap();
|
||||
node.extract(Some("test/output")).unwrap();
|
||||
let tgt = fs::read_link("test/output/test/lilnk.txt").unwrap();
|
||||
assert_eq!(tgt, PathBuf::from("li.txt"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user