Skip to content

Commit

Permalink
Handle symlinks properly and copy them "as is" instead of resolving them
Browse files Browse the repository at this point in the history
  • Loading branch information
isbm committed Jul 2, 2024
1 parent 053fa9b commit 6d40f85
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/procdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,20 @@ impl TintProcessor {
fs::create_dir_all(dst.parent().unwrap())?;
}

fs::copy(src, dst)?;
info!("Archiving {:?}", src);
if !src.is_symlink() {
info!("Archiving {:?} file", src);
fs::copy(src, dst)?;
} else {
info!("Archiving {:?} symlink", src);
let lnk = fs::read_link(src)?;
let _ = unix::fs::symlink(&lnk, dst);
}
}

// targz the content
let archname = format!("{}.tar.gz", tmpdir.as_os_str().to_str().unwrap());
let mut builder = Builder::new(GzEncoder::new(File::create(&archname)?, Compression::best()));
builder.follow_symlinks(false); // don't generate junk
builder.append_dir_all(self.copy_to.to_owned().unwrap().file_name().unwrap().to_str().unwrap(), &tmpdir)?;
builder.into_inner()?.finish()?;

Expand Down

0 comments on commit 6d40f85

Please sign in to comment.