diff options
author | ByteHamster <info@bytehamster.com> | 2020-05-20 10:00:10 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-05-20 10:00:10 +0200 |
commit | fda270575ffc3998e148133a6208a49276fc4b7f (patch) | |
tree | a30f48c6ccd9c9551240ee5c8f73e6e9d994a7b6 /core/src/main/java | |
parent | 62fc413f9c626f4e749d2aa9c4e2e0b7225b16cb (diff) | |
download | AntennaPod-fda270575ffc3998e148133a6208a49276fc4b7f.zip |
Retry gpodder sync before notifying
Diffstat (limited to 'core/src/main/java')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java index f0b34891b..6985e4421 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java @@ -97,7 +97,10 @@ public class SyncService extends Worker { EventBus.getDefault().postSticky(new SyncServiceEvent(R.string.sync_status_error)); prefs.putBoolean(PREF_LAST_SYNC_ATTEMPT_SUCCESS, false).apply(); Log.e(TAG, Log.getStackTraceString(e)); - updateErrorNotification(e); + if (getRunAttemptCount() % 3 == 2) { + // Do not spam users with notification and retry before notifying + updateErrorNotification(e); + } return Result.retry(); } } @@ -192,7 +195,6 @@ public class SyncService extends Worker { OneTimeWorkRequest workRequest = getWorkRequest() .setInitialDelay(0L, TimeUnit.SECONDS) - .setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 1, TimeUnit.MINUTES) .build(); WorkManager.getInstance(context).enqueueUniqueWork(WORK_ID_SYNC, ExistingWorkPolicy.REPLACE, workRequest); EventBus.getDefault().postSticky(new SyncServiceEvent(R.string.sync_status_started)); @@ -209,6 +211,7 @@ public class SyncService extends Worker { return new OneTimeWorkRequest.Builder(SyncService.class) .setConstraints(constraints.build()) + .setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 10, TimeUnit.MINUTES) .setInitialDelay(5L, TimeUnit.SECONDS); // Give it some time, so other actions can be queued } |