diff --git a/CHANGELOG.md b/CHANGELOG.md index a095fe3151..1fba349e19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. ### Fixed * ui: subject dialog for external billing now works in dark mode * ui: external billing icon works with dark mode now +* core: prevent SQLiteLockedException and recover from it on product database update ## [0.75.7] ### Added diff --git a/core/src/main/java/io/snabble/sdk/ProductDatabase.java b/core/src/main/java/io/snabble/sdk/ProductDatabase.java index 60c346df3d..c6721741bc 100644 --- a/core/src/main/java/io/snabble/sdk/ProductDatabase.java +++ b/core/src/main/java/io/snabble/sdk/ProductDatabase.java @@ -6,7 +6,6 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.database.Cursor; -import android.database.sqlite.SQLiteCantOpenDatabaseException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.os.CancellationSignal; @@ -336,9 +335,12 @@ synchronized void applyDeltaUpdate(InputStream inputStream) throws IOException { } final SQLiteDatabase tempDb; + if (!tempDbFile.canRead() || !tempDbFile.canWrite()) + throw new IOException("TempDbFile cannot be read and/or written."); + try { tempDb = SQLiteDatabase.openOrCreateDatabase(tempDbFile, null); - } catch (SQLiteCantOpenDatabaseException e) { + } catch (SQLiteException e) { project.logErrorEvent("Could not open or create db: %s", e.getMessage()); throw new IOException("Could not open or create db", e); }