Skip to content

Commit

Permalink
Close databases after scheduled service is run
Browse files Browse the repository at this point in the history
  • Loading branch information
codinguser committed Sep 17, 2016
1 parent 79bc80e commit 4047596
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ protected void onHandleIntent(Intent intent) {
Log.i(LOG_TAG, String.format("Processing %d total scheduled actions for Book: %s",
scheduledActions.size(), book.getDisplayName()));
processScheduledActions(scheduledActions, db);

//close all databases except the currently active database
if (!db.getPath().equals(GnuCashApplication.getActiveDb().getPath()))
db.close();
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private boolean copy(File src, File dst) throws IOException {
*/
private int recursiveMove(File src, File dst){
int copyCount = 0;
if (src.isDirectory()){
if (src.isDirectory() && src.listFiles() != null){
dst.mkdirs(); //we assume it works everytime. Great, right?
for (File file : src.listFiles()) {
File target = new File(dst, file.getName());
Expand Down

0 comments on commit 4047596

Please sign in to comment.