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

Function WipeCredentialsFile

internal/cli/credentials.go:584–598  ·  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

582// Under the exclusive lock, so it cannot land in the middle of a save
583// (BUG-3649). Never call it from an UpdateStore callback.
584func WipeCredentialsFile() error {
585 // No ~/.pad, nothing to wipe: answered without creating it, which on a
586 // read-only home would fail where the wipe used to succeed.
587 if path, err := credentialsPath(); err == nil {
588 if _, err := os.Stat(filepath.Dir(path)); errors.Is(err, fs.ErrNotExist) {
589 return nil
590 }
591 }
592 return withCredentialsLock(true, func(path string, _ bool) error {
593 if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
594 return fmt.Errorf("delete credentials: %w", err)
595 }
596 return nil
597 })
598}
599
600// normalizeServerURL canonicalizes a server URL for use as a credential
601// 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