Rate limit handling for Dropbox (#6416)

* Added rate limit handling to dropbox

+ some refactor to make the whole file one object

* Added error messages on rate limit reached

+ refactored some popup code to reduce repetition

* Fixed merge error

* Made variables private

* Fixed file upload not working

because of missing override flag for dropbox

* Stop multiplayer refresher if rate limit reached

* Fixed typo

* Various code changes/fixes

- ErrorResponse var name has to be `error` because that's how DropBox's json property is named
- Change FileStorageRateLimitReached exception to store the seconds remaining as its own property instead of in the message
- Use toIntOrNull to avoid setting defaults in two places

* Fixed missed exception message

Co-authored-by: Azzurite <azzurite@gmail.com>
This commit is contained in:
Leonard Günther
2022-05-13 08:16:52 +02:00
committed by GitHub
parent 4ab7d56c14
commit 09b4e82589
10 changed files with 211 additions and 125 deletions

View File

@ -15,6 +15,7 @@ import androidx.work.*
import com.badlogic.gdx.backends.android.AndroidApplication
import com.unciv.logic.GameInfo
import com.unciv.logic.GameSaver
import com.unciv.logic.multiplayer.FileStorageRateLimitReached
import com.unciv.models.metadata.GameSettings
import com.unciv.logic.multiplayer.OnlineMultiplayer
import java.io.FileNotFoundException
@ -269,6 +270,9 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
foundGame = Pair(gameNames[arrayIndex], gameIds[arrayIndex])
}
arrayIndex++
} catch (ex: FileStorageRateLimitReached) {
// We just break here as configuredDelay is probably enough to wait for the rate limit anyway
break
} catch (ex: FileNotFoundException){
// FileNotFoundException is thrown by OnlineMultiplayer().tryDownloadGamePreview(gameId)
// and indicates that there is no game preview present for this game