Skip to content

Safer overwriting #24

@jdahm

Description

@jdahm

I just started testing out this tool the other day and so far it's great!

I began poking around the code and noticed this. It strikes me that the code below is unsafe. For example, if there's a directory or other file there it'll wipe it out without any warning.

lnk/internal/core/lnk.go

Lines 677 to 681 in 430619b

if _, err := os.Lstat(symlinkPath); err == nil {
if err := os.RemoveAll(symlinkPath); err != nil {
return nil, fmt.Errorf("failed to remove existing item %s: %w", symlinkPath, err)
}
}

Would you consider adding an option (maybe on by default) to stop and exit if it detects files, or at the least wait for user input to overwrite it? IIRC chezmoi does this.

There's a chance I'm just misunderstanding the flow of the code. If so please let me know.

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