MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / WipeCredentialsFile

Function WipeCredentialsFile

internal/cli/credentials.go:633–647  ·  view source on GitHub ↗

WipeCredentialsFile removes ~/.pad/credentials.json entirely. Distinct from CredentialStore.Delete (which removes a single server's entry) — used by tests and any future "pad auth wipe" that wants a clean slate. Silently succeeds if the file is already absent. Under the exclusive lock, so it cannot

()

Source from the content-addressed store, hash-verified

631// Under the exclusive lock, so it cannot land in the middle of a save
632// (BUG-3649). Never call it from an UpdateStore callback.
633func WipeCredentialsFile() error {
634 // No ~/.pad, nothing to wipe: answered without creating it, which on a
635 // read-only home would fail where the wipe used to succeed.
636 if path, err := credentialsPath(); err == nil {
637 if _, err := os.Stat(filepath.Dir(path)); errors.Is(err, fs.ErrNotExist) {
638 return nil
639 }
640 }
641 return withCredentialsLock(true, func(path string, _ bool) error {
642 if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
643 return fmt.Errorf("delete credentials: %w", err)
644 }
645 return nil
646 })
647}
648
649// normalizeServerURL canonicalizes a server URL for use as a credential
650// key. Trailing slash and surrounding whitespace are stripped; nothing

Calls 5

credentialsPathFunction · 0.85
withCredentialsLockFunction · 0.85
StatMethod · 0.65
RemoveMethod · 0.65
IsMethod · 0.45