@@ -50,17 +50,19 @@ public class BackupFileHeader {
public static BackupFileHeader read(DataInputStream inputStream) throws IOException {
final int version = inputStream.readInt();
- if (version != VERSION) {- throw new IllegalArgumentException("Backup File version was " + version + " but app only supports version " + VERSION);- }- String app = inputStream.readUTF();- String jid = inputStream.readUTF();
+ final String app = inputStream.readUTF();
+ final String jid = inputStream.readUTF();
long timestamp = inputStream.readLong();
- byte[] iv = new byte[12];
+ final byte[] iv = new byte[12];
inputStream.readFully(iv);
- byte[] salt = new byte[16];
+ final byte[] salt = new byte[16];
inputStream.readFully(salt);
-
+ if (version < VERSION) {
+ throw new OutdatedBackupFileVersion();
+ }
+ if (version != VERSION) {
+ throw new IllegalArgumentException("Backup File version was " + version + " but app only supports version " + VERSION);
+ }
return new BackupFileHeader(app, Jid.of(jid), timestamp, iv, salt);
}
@@ -84,4 +86,8 @@ public class BackupFileHeader {
public long getTimestamp() {
return timestamp;
}
+
+ public static class OutdatedBackupFileVersion extends RuntimeException {
+
+ }
}
@@ -894,6 +894,7 @@
<string name="event">Event</string>
<string name="open_backup">Open backup</string>
<string name="not_a_backup_file">The file you selected is not a Conversations backup file</string>
+ <string name="outdated_backup_file_format">You are trying to import an outdated backup file format</string>
<string name="account_already_setup">This account has already been setup</string>
<string name="please_enter_password">Please enter the password for this account</string>
<string name="unable_to_perform_this_action">Could not perform this action</string>