mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Fix multiple scheduled backups due to jitter.
This commit is contained in:
@@ -49,14 +49,13 @@ public class LocalBackupListener extends PersistentAlarmManagerListener {
|
||||
int minute = SignalStore.settings().getBackupMinute();
|
||||
LocalDateTime next = now.withHour(hour).withMinute(minute).withSecond(0);
|
||||
|
||||
int jitter = (new Random().nextInt(BACKUP_JITTER_WINDOW_SECONDS)) - (BACKUP_JITTER_WINDOW_SECONDS / 2);
|
||||
|
||||
next = next.plusSeconds(jitter);
|
||||
|
||||
if (now.isAfter(next)) {
|
||||
next = next.plusDays(1);
|
||||
}
|
||||
|
||||
int jitter = (new Random().nextInt(BACKUP_JITTER_WINDOW_SECONDS)) - (BACKUP_JITTER_WINDOW_SECONDS / 2);
|
||||
next = next.plusSeconds(jitter);
|
||||
|
||||
long nextTime = JavaTimeExtensionsKt.toMillis(next);
|
||||
|
||||
TextSecurePreferences.setNextBackupTime(context, nextTime);
|
||||
|
||||
Reference in New Issue
Block a user