diff --git a/app/src/main/java/org/gnucash/android/service/ScheduledActionService.java b/app/src/main/java/org/gnucash/android/service/ScheduledActionService.java index e0e7095e3..b1a3f7a11 100644 --- a/app/src/main/java/org/gnucash/android/service/ScheduledActionService.java +++ b/app/src/main/java/org/gnucash/android/service/ScheduledActionService.java @@ -179,7 +179,14 @@ private static int executeBackup(ScheduledAction scheduledAction, SQLiteDatabase Crashlytics.logException(e); Log.e(LOG_TAG, e.getMessage()); } - Log.i(LOG_TAG, "Backup/export did not occur. There might have beeen no new transactions to export or it might have crashed"); + if (!result) { + Log.i(LOG_TAG, "Backup/export did not occur. There might have been no" + + " new transactions to export or it might have crashed"); + // We don't know if something failed or there weren't transactions to export, + // so fall on the safe side and return as if something had failed. + // FIXME: Change ExportAsyncTask to distinguish between the two cases + return 0; + } return 1; } diff --git a/app/src/test/java/org/gnucash/android/test/unit/service/ScheduledActionServiceTest.java b/app/src/test/java/org/gnucash/android/test/unit/service/ScheduledActionServiceTest.java index d0a974803..e4b3a6d5e 100644 --- a/app/src/test/java/org/gnucash/android/test/unit/service/ScheduledActionServiceTest.java +++ b/app/src/test/java/org/gnucash/android/test/unit/service/ScheduledActionServiceTest.java @@ -381,8 +381,8 @@ public void scheduledBackups_shouldNotRunBeforeNextScheduledExecution(){ } /** - * Tests that an scheduled backup doesn't include transactions added or modified - * previous to the last run. + * Tests that a scheduled QIF backup isn't done when no transactions have + * been added or modified after the last run. */ @Test public void scheduledBackups_shouldNotIncludeTransactionsPreviousToTheLastRun() { @@ -422,8 +422,8 @@ public void scheduledBackups_shouldNotIncludeTransactionsPreviousToTheLastRun() actions.add(scheduledBackup); ScheduledActionService.processScheduledActions(actions, mDb); - assertThat(scheduledBackup.getExecutionCount()).isEqualTo(2); - assertThat(scheduledBackup.getLastRunTime()).isGreaterThan(previousLastRun); + assertThat(scheduledBackup.getExecutionCount()).isEqualTo(1); + assertThat(scheduledBackup.getLastRunTime()).isEqualTo(previousLastRun); assertThat(backupFolder.listFiles()).hasSize(0); }