Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

remove probable existing symbolic link #139

Closed
wants to merge 2 commits into from
Closed

Conversation

meysampg
Copy link

On some extracting situations that an archive contains a symbolic link file,
archiver tries to create a symbolic link, but already the symbolic file
exists and it causes the file exists error. This commit adds a blind
removing try: if the symbolic link already exists (from extraction process),
remove it and if does not, ignore the returned error.

archiver.go Outdated
@@ -310,6 +310,7 @@ func writeNewSymbolicLink(fpath string, target string) error {
if err != nil {
return fmt.Errorf("%s: making directory for file: %v", fpath, err)
}
os.Remove(fpath)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only remove it if it's a symbolic link, right? Not safe to overwrite existing files with actual content.

Also might need to honor the various OverwriteExisting parameters for each archiver, for example, zip's:

OverwriteExisting bool

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mholt Please consider new changes.
Now zip and tar archives which currently use writeNewSymbolicLink method, use their OverwriteExisting to remove existing symbolic links safely.

@mholt
Copy link
Owner

mholt commented Jan 4, 2022

I believe #302 makes this irrelevant -- thank you for the contribution. Sorry I never got around to finishing it with you.

@mholt mholt closed this Jan 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants