Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fast path in atomicSymlink #709

Merged
merged 1 commit into from
Jan 13, 2025
Merged

Fix fast path in atomicSymlink #709

merged 1 commit into from
Jan 13, 2025

Conversation

linyinfeng
Copy link
Contributor

Fix #708.

  1. If os.Symlink succeeds (err == nil), return nil (err).
  2. If os.Symlink fails (err != nil), check if the error indicates that a file or directory already exists (os.IsExist(err)).
    • If the error is unrelated to a pre-existing file or directory, return err as it cannot be handled in atomicSymlink.
    • If the error does indicate a pre-existing file or directory, don't return and handle it with the remaining logic in atomicSymlink.
// Fast path: if newname does not exist yet, we can skip the whole dance
// below.
if err := os.Symlink(oldname, newname); err == nil || !os.IsExist(err) {
    return err
}

@Mic92 Mic92 merged commit 0f4744b into Mic92:master Jan 13, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sops-install-secrets(-for-users).service failed with recent commit f214c1b
2 participants