fix: store item type & update file check

This commit is contained in:
lollipopkit
2023-10-28 19:02:54 +08:00
parent c3ca5725a4
commit 7de5987355
7 changed files with 38 additions and 29 deletions

View File

@@ -65,7 +65,11 @@ class StoreProperty<T> implements StorePropertyBase<T> {
@override
T fetch() {
return _box.get(_key, defaultValue: defaultValue)!;
final stored = _box.get(_key);
if (stored == null || stored is! T) {
return defaultValue;
}
return stored;
}
@override

View File

@@ -6,6 +6,7 @@ import 'package:r_upgrade/r_upgrade.dart';
import 'package:toolbox/core/extension/context/dialog.dart';
import 'package:toolbox/core/extension/context/locale.dart';
import 'package:toolbox/core/extension/context/snackbar.dart';
import 'package:toolbox/core/utils/misc.dart';
import 'package:toolbox/core/utils/platform/base.dart';
import 'package:toolbox/data/model/app/update.dart';
import 'package:toolbox/data/res/logger.dart';
@@ -48,7 +49,7 @@ Future<void> doUpdate(BuildContext context, {bool force = false}) async {
final url = update.url.current!;
if ((isAndroid || isMacOS) && !await isFileAvailable(url)) {
if (isFileUrl(url) && !await isFileAvailable(url)) {
Loggers.app.warning('Update file not available');
return;
}

View File

@@ -34,3 +34,6 @@ String? getFileName(String? path) {
String pathJoin(String path1, String path2) {
return path1 + (path1.endsWith('/') ? '' : '/') + path2;
}
/// Check if a url is a file url (ends with a file extension)
bool isFileUrl(String url) => url.split('/').last.contains('.');