Skip to content

Commit 131c534

Browse files
committed
Fix ScheduledActionService.executeBackup not checking the return value from the export task
1 parent cfce758 commit 131c534

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,14 @@ private static int executeBackup(ScheduledAction scheduledAction, SQLiteDatabase
179179
Crashlytics.logException(e);
180180
Log.e(LOG_TAG, e.getMessage());
181181
}
182-
Log.i(LOG_TAG, "Backup/export did not occur. There might have beeen no new transactions to export or it might have crashed");
182+
if (!result) {
183+
Log.i(LOG_TAG, "Backup/export did not occur. There might have been no"
184+
+ " new transactions to export or it might have crashed");
185+
// We don't know if something failed or there weren't transactions to export,
186+
// so fall on the safe side and return as if something had failed.
187+
// FIXME: Change ExportAsyncTask to distinguish between the two cases
188+
return 0;
189+
}
183190
return 1;
184191
}
185192

app/src/test/java/org/gnucash/android/test/unit/service/ScheduledActionServiceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ public void scheduledBackups_shouldNotRunBeforeNextScheduledExecution(){
381381
}
382382

383383
/**
384-
* Tests that an scheduled backup doesn't include transactions added or modified
385-
* previous to the last run.
384+
* Tests that a scheduled QIF backup isn't done when no transactions have
385+
* been added or modified after the last run.
386386
*/
387387
@Test
388388
public void scheduledBackups_shouldNotIncludeTransactionsPreviousToTheLastRun() {
@@ -422,8 +422,8 @@ public void scheduledBackups_shouldNotIncludeTransactionsPreviousToTheLastRun()
422422
actions.add(scheduledBackup);
423423
ScheduledActionService.processScheduledActions(actions, mDb);
424424

425-
assertThat(scheduledBackup.getExecutionCount()).isEqualTo(2);
426-
assertThat(scheduledBackup.getLastRunTime()).isGreaterThan(previousLastRun);
425+
assertThat(scheduledBackup.getExecutionCount()).isEqualTo(1);
426+
assertThat(scheduledBackup.getLastRunTime()).isEqualTo(previousLastRun);
427427
assertThat(backupFolder.listFiles()).hasSize(0);
428428
}
429429

0 commit comments

Comments
 (0)