]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix a hanging db transaction wen applying DB revisions
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 7 Dec 2018 05:55:50 +0000 (05:55 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 7 Dec 2018 05:55:50 +0000 (05:55 +0000)
app/src/main/java/net/ktnx/mobileledger/MobileLedgerDB.java

index 2254cae784be0ad64ec1d3b05a03adc0772837d7..141b4a321f5cf9d304513c99bf90bb9ba290e03a 100644 (file)
@@ -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);