Compare commits

...

1 Commits

Author SHA1 Message Date
a954a627fd Fixed 2 issues:
- Rate-limit regression in previous release
- Update notifications not sent when >1 apps have errors
2022-10-11 18:39:53 -04:00
3 changed files with 16 additions and 5 deletions

View File

@ -14,7 +14,7 @@ import 'package:dynamic_color/dynamic_color.dart';
import 'package:device_info_plus/device_info_plus.dart';
const String currentReleaseTag =
'v0.5.9-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
'v0.5.10-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
const String bgUpdateCheckTaskName = 'bg-update-check';
@ -31,8 +31,10 @@ bgUpdateCheck(int? ignoreAfterMicroseconds) async {
List<String> existingUpdateIds =
appsProvider.getExistingUpdates(installedOnly: true);
DateTime nextIgnoreAfter = DateTime.now();
String? err;
try {
await appsProvider.checkUpdates(ignoreAfter: ignoreAfter);
await appsProvider.checkUpdates(
ignoreAfter: ignoreAfter, immediatelyThrowRateLimitError: true);
} catch (e) {
if (e is RateLimitError) {
String nextTaskName =
@ -42,7 +44,7 @@ bgUpdateCheck(int? ignoreAfterMicroseconds) async {
initialDelay: Duration(minutes: e.remainingMinutes),
inputData: {'ignoreAfter': nextIgnoreAfter.microsecondsSinceEpoch});
} else {
rethrow;
err = e.toString();
}
}
List<App> newUpdates = appsProvider
@ -69,6 +71,9 @@ bgUpdateCheck(int? ignoreAfterMicroseconds) async {
notificationsProvider.notify(UpdateNotification(newUpdates),
cancelExisting: true);
}
if (err != null) {
throw err;
}
return Future.value(true);
} catch (e) {
notificationsProvider.notify(ErrorCheckingUpdatesNotification(e.toString()),

View File

@ -10,6 +10,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:install_plugin_v2/install_plugin_v2.dart';
import 'package:obtainium/app_sources/github.dart';
import 'package:obtainium/custom_errors.dart';
import 'package:obtainium/providers/notifications_provider.dart';
import 'package:provider/provider.dart';
import 'package:path_provider/path_provider.dart';
@ -323,7 +324,9 @@ class AppsProvider with ChangeNotifier {
return newApp.latestVersion != currentApp.latestVersion ? newApp : null;
}
Future<List<App>> checkUpdates({DateTime? ignoreAfter}) async {
Future<List<App>> checkUpdates(
{DateTime? ignoreAfter,
bool immediatelyThrowRateLimitError = false}) async {
List<App> updates = [];
Map<String, List<String>> errors = {};
if (!gettingUpdates) {
@ -347,6 +350,9 @@ class AppsProvider with ChangeNotifier {
try {
newApp = await getUpdate(appIds[i]);
} catch (e) {
if (e is RateLimitError && immediatelyThrowRateLimitError) {
rethrow;
}
var tempIds = errors.remove(e.toString());
tempIds ??= [];
tempIds.add(appIds[i]);

View File

@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 0.5.9+30 # When changing this, update the tag in main() accordingly
version: 0.5.10+31 # When changing this, update the tag in main() accordingly
environment:
sdk: '>=2.19.0-79.0.dev <3.0.0'