Fix secrets not being properly rewritten when passphrase is removed

This commit is contained in:
crschnick 2024-05-12 08:11:47 +00:00
parent 4fc95833e5
commit e32ee4da2f

View file

@ -36,9 +36,21 @@ public class DataStoreSecret {
}
public boolean requiresRewrite() {
return AppPrefs.get() != null
&& AppPrefs.get().getLockCrypt().get() != null
&& !Objects.equals(AppPrefs.get().getLockCrypt().get(), usedPasswordLockCrypt);
if (AppPrefs.get() == null) {
return false;
}
// Special check for empty passphrases
var wasEmpty = usedPasswordLockCrypt == null || usedPasswordLockCrypt.isEmpty();
var isEmpty = AppPrefs.get().getLockCrypt().get() == null || AppPrefs.get().getLockCrypt().get().isEmpty();
if (wasEmpty && isEmpty) {
return false;
}
if (wasEmpty != isEmpty) {
return true;
}
return !Objects.equals(AppPrefs.get().getLockCrypt().get(), usedPasswordLockCrypt);
}
public char[] getSecret() {