Skip to content

Commit 343013d

Browse files
committed
catching sqliteexception when the temp database is locked after copying it
1 parent 48c4f5e commit 343013d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

core/src/main/java/io/snabble/sdk/ProductDatabase.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,13 @@ void applyDeltaUpdate(InputStream inputStream) throws IOException {
324324
//occurrences in database rows
325325
scanner.useDelimiter(";\n\n");
326326

327-
tempDb.beginTransaction();
327+
try {
328+
tempDb.beginTransaction();
329+
} catch (SQLiteException e){
330+
Logger.e("Could not apply delta update: Could not access temp database");
331+
return;
332+
}
333+
328334
while (scanner.hasNext()) {
329335
try {
330336
String line = scanner.next();
@@ -353,8 +359,13 @@ void applyDeltaUpdate(InputStream inputStream) throws IOException {
353359
}
354360
}
355361

356-
tempDb.setTransactionSuccessful();
357-
tempDb.endTransaction();
362+
try {
363+
tempDb.setTransactionSuccessful();
364+
tempDb.endTransaction();
365+
} catch (SQLiteException e){
366+
Logger.e("Could not apply delta update: Could not finish transaction on temp database");
367+
return;
368+
}
358369

359370
//delta updates are making the database grow larger and larger, so we vacuum here
360371
//to keep the database as small as possible

0 commit comments

Comments
 (0)