The info command should not overwrite the default password if reset-passwords is on

This commit is contained in:
Gilbert Chen
2017-09-26 10:37:06 -04:00
parent 8841ced1f5
commit ce52ec1e5d

View File

@@ -1122,6 +1122,7 @@ func infoStorage(context *cli.Context) {
duplicacy.SetKeyringFile(path.Join(preferencePath, "keyring")) duplicacy.SetKeyringFile(path.Join(preferencePath, "keyring"))
} }
resetPasswords := context.Bool("reset-passwords")
isEncrypted := context.Bool("e") isEncrypted := context.Bool("e")
preference := duplicacy.Preference{ preference := duplicacy.Preference{
Name: "default", Name: "default",
@@ -1131,12 +1132,18 @@ func infoStorage(context *cli.Context) {
DoNotSavePassword: true, DoNotSavePassword: true,
} }
password := "" if resetPasswords {
if isEncrypted { // We don't want password entered for the info command to overwrite the saved password for the default storage,
password = duplicacy.GetPassword(preference, "password", "Enter the storage password:", false, false) // so we simply assign an empty name.
preference.Name = ""
} }
storage := duplicacy.CreateStorage(preference, context.Bool("reset-passwords"), 1) password := ""
if isEncrypted {
password = duplicacy.GetPassword(preference, "password", "Enter the storage password:", false, resetPasswords)
}
storage := duplicacy.CreateStorage(preference, resetPasswords, 1)
config, isStorageEncrypted, err := duplicacy.DownloadConfig(storage, password) config, isStorageEncrypted, err := duplicacy.DownloadConfig(storage, password)
if isStorageEncrypted { if isStorageEncrypted {