mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-10-22 18:33:45 +02:00
Max 5 attempts for bg check fail due to rate/net
This commit is contained in:
@@ -105,6 +105,12 @@ Future<void> bgUpdateCheckApp(int taskId, Map<String, dynamic>? params) async {
|
|||||||
AppsProvider appsProvider = AppsProvider();
|
AppsProvider appsProvider = AppsProvider();
|
||||||
|
|
||||||
String appId = params!['appId'];
|
String appId = params!['appId'];
|
||||||
|
params['attemptCount'] = (params['attemptCount'] ?? 0) + 1;
|
||||||
|
int maxAttempts = 5;
|
||||||
|
if (params['attemptCount'] > 1) {
|
||||||
|
logs.add(
|
||||||
|
'BG update check for $appId: Note this is attempt #${params['attemptCount']} of $maxAttempts');
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await appsProvider.loadApps(singleId: appId);
|
await appsProvider.loadApps(singleId: appId);
|
||||||
AppInMemory app = appsProvider.apps[appId]!;
|
AppInMemory app = appsProvider.apps[appId]!;
|
||||||
@@ -117,7 +123,8 @@ Future<void> bgUpdateCheckApp(int taskId, Map<String, dynamic>? params) async {
|
|||||||
newApp = await appsProvider.checkUpdate(appId);
|
newApp = await appsProvider.checkUpdate(appId);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logs.add('BG update check for $appId got error \'${e.toString()}\'.');
|
logs.add('BG update check for $appId got error \'${e.toString()}\'.');
|
||||||
if (e is RateLimitError || e is ClientException) {
|
if (e is RateLimitError ||
|
||||||
|
e is ClientException && params['attemptCount'] < maxAttempts) {
|
||||||
var remainingMinutes = e is RateLimitError ? e.remainingMinutes : 15;
|
var remainingMinutes = e is RateLimitError ? e.remainingMinutes : 15;
|
||||||
logs.add(
|
logs.add(
|
||||||
'BG update check for $appId will be retried in $remainingMinutes minutes.');
|
'BG update check for $appId will be retried in $remainingMinutes minutes.');
|
||||||
|
Reference in New Issue
Block a user