refactor(GoogleDrive): update backoff delay.

Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
KaiserBh 2024-01-10 11:30:15 +11:00
parent e04d191dfb
commit a13e731d1c
No known key found for this signature in database
GPG Key ID: 14D73B142042BBA9

View File

@ -71,7 +71,7 @@ class GoogleDriveSyncService(context: Context, json: Json, syncPreferences: Sync
googleDriveService.refreshToken() googleDriveService.refreshToken()
val drive = googleDriveService.driveService ?: throw Exception("Google Drive service not initialized") val drive = googleDriveService.driveService ?: throw Exception("Google Drive service not initialized")
var backoff = 2000L var backoff = 1000L
while (true) { while (true) {
val lockFiles = findLockFile(drive) val lockFiles = findLockFile(drive)
@ -99,7 +99,7 @@ class GoogleDriveSyncService(context: Context, json: Json, syncPreferences: Sync
else -> { else -> {
logcat(LogPriority.DEBUG) { "Multiple lock files found, applying backoff" } logcat(LogPriority.DEBUG) { "Multiple lock files found, applying backoff" }
delay(backoff) // Apply backoff strategy delay(backoff) // Apply backoff strategy
backoff = (backoff * 2).coerceAtMost(32000L) backoff = (backoff * 2).coerceAtMost(16000L)
logcat(LogPriority.DEBUG) { "Backoff increased to $backoff milliseconds" } logcat(LogPriority.DEBUG) { "Backoff increased to $backoff milliseconds" }
} }
} }