From: Damyan Ivanov Date: Fri, 7 Dec 2018 05:55:50 +0000 (+0000) Subject: fix a hanging db transaction wen applying DB revisions X-Git-Tag: v0.3~306 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=102232aaa4e22cd942ed305952c618f460b410fe;p=mobile-ledger.git fix a hanging db transaction wen applying DB revisions --- diff --git a/app/src/main/java/net/ktnx/mobileledger/MobileLedgerDB.java b/app/src/main/java/net/ktnx/mobileledger/MobileLedgerDB.java index 2254cae7..141b4a32 100644 --- a/app/src/main/java/net/ktnx/mobileledger/MobileLedgerDB.java +++ b/app/src/main/java/net/ktnx/mobileledger/MobileLedgerDB.java @@ -51,12 +51,12 @@ class MobileLedgerDB { private static boolean applyRevision(Resources rm, String pkg_name, int rev_no) { String rev_file = String.format(Locale.US, "sql_%d", rev_no); - db.beginTransaction(); int res_id = rm.getIdentifier(rev_file, "raw", pkg_name); if (res_id == 0) { Log.d("db", String.format(Locale.US, "No resource for revision %d", rev_no)); return false; } + db.beginTransaction(); try (InputStream res = rm.openRawResource(res_id)) { Log.d("db", "Applying revision " + String.valueOf(rev_no)); InputStreamReader isr = new InputStreamReader(res);