GODT-2173: fix: do not migrate keychain once migrated

This commit is contained in:
Jakub
2022-12-12 17:06:43 +01:00
committed by Jakub Cuth
parent ebb04d8a14
commit 57d563d488
3 changed files with 64 additions and 7 deletions

View File

@ -29,8 +29,12 @@ type Keychain struct {
Helper string
}
func getKeychainPrefPath(vaultDir string) string {
return filepath.Clean(filepath.Join(vaultDir, "keychain.json"))
}
func GetHelper(vaultDir string) (string, error) {
filePath := filepath.Clean(filepath.Join(vaultDir, "keychain.json"))
filePath := getKeychainPrefPath(vaultDir)
if _, err := os.Stat(filePath); errors.Is(err, fs.ErrNotExist) {
return "", nil
@ -56,5 +60,5 @@ func SetHelper(vaultDir, helper string) error {
return err
}
return os.WriteFile(filepath.Clean(filepath.Join(vaultDir, "keychain.json")), b, 0o600)
return os.WriteFile(getKeychainPrefPath(vaultDir), b, 0o600)
}