Use backup with highest version number

This commit is contained in:
ameba23
2021-04-21 21:53:06 +02:00
parent 327cbe23ee
commit 4b77a9ab60

View File

@@ -60,11 +60,17 @@ public class RestoreAccountImpl implements RestoreAccount {
public int recover() throws FormatException, GeneralSecurityException { public int recover() throws FormatException, GeneralSecurityException {
if (secretKey == null) throw new GeneralSecurityException(); if (secretKey == null) throw new GeneralSecurityException();
// TODO find backup with highest version number // Find backup with highest version number
BackupPayload backupPayload = recoveredShards.get(0).getBackupPayload(); int highestVersion = 0;
socialBackup = backupPayloadDecoder.decodeBackupPayload(secretKey, backupPayload); for (ReturnShardPayload returnShardPayload : recoveredShards) {
int version = socialBackup.getVersion(); BackupPayload backupPayload = returnShardPayload.getBackupPayload();
return version; SocialBackup s = backupPayloadDecoder.decodeBackupPayload(secretKey, backupPayload);
if (s.getVersion() > highestVersion) {
socialBackup = s;
highestVersion = s.getVersion();
}
}
return highestVersion;
} }
public SocialBackup getSocialBackup() { public SocialBackup getSocialBackup() {