Description
What version of the package or command are you using?
v4.0.0-alpha.8
What are you trying to do?
I've got a process that archives nested folders on a server.
I'm trying to compress directories containing symlinks, some of which may point to things that no longer exist.
I am getting the error open symlink.file: no such file or directory
even though I have FollowSymlinks: false,
What steps did you take?
https://github.com/donatj/archivertest - here's the problem boiled down to an example project.
The gist of that project is
zf, err := os.Create("output.zip")
if err != nil {
log.Fatal("error creating zip file", err)
}
filesForZip, err := archiver.FilesFromDisk(&archiver.FromDiskOptions{
FollowSymlinks: false,
}, map[string]string{
"toArchive": "toArchive",
})
if err != nil {
log.Fatal("error walking files to create archive", err)
}
format := archiver.CompressedArchive{
Archival: archiver.Zip{
SelectiveCompression: true,
},
}
// create the archive
err = format.Archive(context.Background(), zf, filesForZip)
if err != nil {
log.Fatal("error creating archive", err)
}
The toArchive
directory contains a link-logo.png symlink that points to a logo.png
that no longer exists.
$ go run .
2024/01/05 17:23:58 error creating archivewriting file 1: link-logo.png: open toArchive/link-logo.png: no such file or directory
exit status 1
What did you expect to happen, and what actually happened instead?
I just a zip with the broken symlink in it like most compression tools give. This throws an error.
How do you think this should be fixed?
Some part of the code is trying to follow the symlink, even though FollowSymlinks is turned off. That should be corrected and the symlink should just be archived as-is.
Please link to any related issues, pull requests, and/or discussion
Example project
https://github.com/donatj/archivertest
Bonus: Wha 4C92 t do you use archiver for, and do you find it useful?
I've got a number of CLI tools using it for creating archives.