catch IllegalArgumentException when reading backup file
This commit is contained in:
parent
4957e50ac4
commit
238df77a1e
|
@ -137,7 +137,7 @@ public class ImportBackupService extends Service {
|
||||||
} else {
|
} else {
|
||||||
backupFiles.add(backupFile);
|
backupFiles.add(backupFile);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException | IllegalArgumentException e) {
|
||||||
Log.d(Config.LOGTAG, "unable to read backup file ", e);
|
Log.d(Config.LOGTAG, "unable to read backup file ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo
|
||||||
try {
|
try {
|
||||||
final ImportBackupService.BackupFile backupFile = ImportBackupService.BackupFile.read(this, uri);
|
final ImportBackupService.BackupFile backupFile = ImportBackupService.BackupFile.read(this, uri);
|
||||||
showEnterPasswordDialog(backupFile, finishOnCancel);
|
showEnterPasswordDialog(backupFile, finishOnCancel);
|
||||||
} catch (IOException e) {
|
} catch (IOException | IllegalArgumentException e) {
|
||||||
Snackbar.make(binding.coordinator, R.string.not_a_backup_file, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(binding.coordinator, R.string.not_a_backup_file, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class BackupFileHeader {
|
||||||
public static BackupFileHeader read(DataInputStream inputStream) throws IOException {
|
public static BackupFileHeader read(DataInputStream inputStream) throws IOException {
|
||||||
final int version = inputStream.readInt();
|
final int version = inputStream.readInt();
|
||||||
if (version > VERSION) {
|
if (version > VERSION) {
|
||||||
throw new IllegalArgumentException("Backup File version was "+version+" but app only supports up to version "+VERSION);
|
throw new IllegalArgumentException("Backup File version was " + version + " but app only supports up to version " + VERSION);
|
||||||
}
|
}
|
||||||
String app = inputStream.readUTF();
|
String app = inputStream.readUTF();
|
||||||
String jid = inputStream.readUTF();
|
String jid = inputStream.readUTF();
|
||||||
|
@ -59,7 +59,7 @@ public class BackupFileHeader {
|
||||||
byte[] salt = new byte[16];
|
byte[] salt = new byte[16];
|
||||||
inputStream.readFully(salt);
|
inputStream.readFully(salt);
|
||||||
|
|
||||||
return new BackupFileHeader(app,Jid.of(jid),timestamp,iv,salt);
|
return new BackupFileHeader(app, Jid.of(jid), timestamp, iv, salt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue