Skip to content

Commit 4047596

Browse files
committed
Close databases after scheduled service is run
1 parent 79bc80e commit 4047596

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

app/src/main/java/org/gnucash/android/service/ScheduledActionService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ protected void onHandleIntent(Intent intent) {
8282
Log.i(LOG_TAG, String.format("Processing %d total scheduled actions for Book: %s",
8383
scheduledActions.size(), book.getDisplayName()));
8484
processScheduledActions(scheduledActions, db);
85+
86+
//close all databases except the currently active database
87+
if (!db.getPath().equals(GnuCashApplication.getActiveDb().getPath()))
88+
db.close();
8589
}
8690

8791
Log.i(LOG_TAG, "Completed service @ " + java.text.DateFormat.getDateTimeInstance().format(new Date()));
@@ -195,7 +199,7 @@ private static int executeTransactions(ScheduledAction scheduledAction, SQLiteDa
195199
try {
196200
trxnTemplate = transactionsDbAdapter.getRecord(actionUID);
197201
} catch (IllegalArgumentException ex){ //if the record could not be found, abort
198-
Log.e(LOG_TAG, "Scheduled action with UID " + actionUID + " could not be found in the db with path " + db.getPath());
202+
Log.e(LOG_TAG, "Scheduled transaction with UID " + actionUID + " could not be found in the db with path " + db.getPath());
199203
return executionCount;
200204
}
201205

app/src/main/java/org/gnucash/android/util/RecursiveMoveFiles.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private boolean copy(File src, File dst) throws IOException {
7474
*/
7575
private int recursiveMove(File src, File dst){
7676
int copyCount = 0;
77-
if (src.isDirectory()){
77+
if (src.isDirectory() && src.listFiles() != null){
7878
dst.mkdirs(); //we assume it works everytime. Great, right?
7979
for (File file : src.listFiles()) {
8080
File target = new File(dst, file.getName());

0 commit comments

Comments
 (0)