catch outdated backup exception in ImportBackupActivity

This commit is contained in:
Daniel Gultsch 2023-10-31 08:32:48 +01:00
parent dfd7410b1a
commit e1b53cdaf6
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2

View file

@ -26,6 +26,19 @@ import com.google.common.io.CountingInputStream;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonToken;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.persistance.DatabaseBackend;
import eu.siacs.conversations.persistance.FileBackend;
import eu.siacs.conversations.ui.ManageAccountActivity;
import eu.siacs.conversations.utils.BackupFileHeader;
import eu.siacs.conversations.utils.SerialSingleThreadExecutor;
import eu.siacs.conversations.xmpp.Jid;
import org.bouncycastle.crypto.engines.AESEngine; import org.bouncycastle.crypto.engines.AESEngine;
import org.bouncycastle.crypto.io.CipherInputStream; import org.bouncycastle.crypto.io.CipherInputStream;
import org.bouncycastle.crypto.modes.AEADBlockCipher; import org.bouncycastle.crypto.modes.AEADBlockCipher;
@ -56,19 +69,6 @@ import java.util.zip.ZipException;
import javax.crypto.BadPaddingException; import javax.crypto.BadPaddingException;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.persistance.DatabaseBackend;
import eu.siacs.conversations.persistance.FileBackend;
import eu.siacs.conversations.ui.ManageAccountActivity;
import eu.siacs.conversations.utils.BackupFileHeader;
import eu.siacs.conversations.utils.SerialSingleThreadExecutor;
import eu.siacs.conversations.xmpp.Jid;
public class ImportBackupService extends Service { public class ImportBackupService extends Service {
private static final int NOTIFICATION_ID = 21; private static final int NOTIFICATION_ID = 21;
@ -92,7 +92,6 @@ public class ImportBackupService extends Service {
SQLiteAxolotlStore.IDENTITIES_TABLENAME); SQLiteAxolotlStore.IDENTITIES_TABLENAME);
private static final Pattern COLUMN_PATTERN = Pattern.compile("^[a-zA-Z_]+$"); private static final Pattern COLUMN_PATTERN = Pattern.compile("^[a-zA-Z_]+$");
@Override @Override
public void onCreate() { public void onCreate() {
mDatabaseBackend = DatabaseBackend.getInstance(getBaseContext()); mDatabaseBackend = DatabaseBackend.getInstance(getBaseContext());
@ -167,6 +166,7 @@ public class ImportBackupService extends Service {
if (files == null) { if (files == null) {
continue; continue;
} }
Log.d(Config.LOGTAG, "looking for backups in " + directory);
for (final File file : files) { for (final File file : files) {
if (file.isFile() && file.getName().endsWith(".ceb")) { if (file.isFile() && file.getName().endsWith(".ceb")) {
try { try {
@ -179,7 +179,9 @@ public class ImportBackupService extends Service {
} else { } else {
backupFiles.add(backupFile); backupFiles.add(backupFile);
} }
} catch (IOException | IllegalArgumentException e) { } catch (final IOException
| IllegalArgumentException
| BackupFileHeader.OutdatedBackupFileVersion e) {
Log.d(Config.LOGTAG, "unable to read backup file ", e); Log.d(Config.LOGTAG, "unable to read backup file ", e);
} }
} }