diff --git a/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java b/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java
index 6e4815159..ed998677b 100644
--- a/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java
+++ b/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java
@@ -30,6 +30,7 @@ import eu.siacs.conversations.databinding.DialogEnterPasswordBinding;
import eu.siacs.conversations.services.ImportBackupService;
import eu.siacs.conversations.ui.adapter.BackupFileAdapter;
import eu.siacs.conversations.ui.util.SettingsUtils;
+import eu.siacs.conversations.utils.BackupFileHeader;
import eu.siacs.conversations.utils.ThemeHelper;
public class ImportBackupActivity extends ActionBarActivity implements ServiceConnection, ImportBackupService.OnBackupFilesLoaded, BackupFileAdapter.OnItemClickedListener, ImportBackupService.OnBackupProcessed {
@@ -131,6 +132,8 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo
try {
final ImportBackupService.BackupFile backupFile = ImportBackupService.BackupFile.read(this, uri);
showEnterPasswordDialog(backupFile, finishOnCancel);
+ } catch (final BackupFileHeader.OutdatedBackupFileVersion e) {
+ Snackbar.make(binding.coordinator, R.string.outdated_backup_file_format, Snackbar.LENGTH_LONG).show();
} catch (final IOException | IllegalArgumentException e) {
Log.d(Config.LOGTAG, "unable to open backup file " + uri, e);
Snackbar.make(binding.coordinator, R.string.not_a_backup_file, Snackbar.LENGTH_LONG).show();
diff --git a/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java b/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java
index 957ccfca1..3b536c27a 100644
--- a/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java
+++ b/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java
@@ -50,17 +50,19 @@ public class BackupFileHeader {
public static BackupFileHeader read(DataInputStream inputStream) throws IOException {
final int version = inputStream.readInt();
+ final String app = inputStream.readUTF();
+ final String jid = inputStream.readUTF();
+ long timestamp = inputStream.readLong();
+ final byte[] iv = new byte[12];
+ inputStream.readFully(iv);
+ 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);
}
- String app = inputStream.readUTF();
- String jid = inputStream.readUTF();
- long timestamp = inputStream.readLong();
- byte[] iv = new byte[12];
- inputStream.readFully(iv);
- byte[] salt = new byte[16];
- inputStream.readFully(salt);
-
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 {
+
+ }
}
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index d3af22e15..84b2cb61e 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -894,6 +894,7 @@
Event
Open backup
The file you selected is not a Conversations backup file
+ You are trying to import an outdated backup file format
This account has already been setup
Please enter the password for this account
Could not perform this action