Skip to content

Commit

Permalink
Fix unhandeld SQLiteException (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabtron authored Sep 17, 2024
1 parent 5433a09 commit 1bb1124
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/java/io/snabble/sdk/ProductDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 1bb1124

Please sign in to comment.