8000 Can't create archive with broken symlinks · Issue #392 · mholt/archiver · GitHub 8000
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Can't create archive with broken symlinks #392
Open
@donatj

Description

@donatj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0