Skip to content

Cannot overwrite existing directory if symlink present (OSX) #20

Open

Description

@marwanhilmi

Let's say I have x.zip with contains a symlink and I unzip the first time to /foo.
If I try to unzip the same zip (or another zip containing the same symlink) to /foo it will fail with EEXIST. Regular files overwrite as expected (ie fs.writestream by default will overwrite). Unfortunately fs.symlink fails if the symlink already exists.

I can make a PR but do you have any suggestions on how to proceed?
I was thinking we check if the symlink already exists and delete before creating the new symlink.

Furthermore - should overwrite be set by flag (for the regular files as well)?

Activity

  1. max-mapper commented on Jan 20, 2016

    @max-mapper
    Owner

    Hmm good question, @mafintosh what do you think we should do here?

  2. canoztokmak commented on Jul 11, 2016

    @canoztokmak

    having the same issue here..

  3. cyberalien commented on Sep 8, 2018

    @cyberalien

    I had same issue. Temporary workaround is to unlink existing file in onEntry event:

        extract(archive, {
            dir: dir,
            onEntry: (entry, zipfile) => {
                try {
                    fs.unlinkSync(dir + '/' + entry.fileName);
                } catch (err) {
                }
            }
        }, err => {
           // ... do stuff
        });
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions