mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
fix: store item type & update file check
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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('.');
|
||||
|
||||
Reference in New Issue
Block a user