improve downloading data

This commit is contained in:
2025-01-22 22:03:46 +08:00
parent 8e2520f8e8
commit 5ef973cbfb

View File

@@ -176,8 +176,11 @@ class DataSync with ChangeNotifier {
var files = await client.readDir('/');
files.sort((a, b) => b.name!.compareTo(a.name!));
var file = files.firstWhereOrNull((e) => e.name!.endsWith('.venera'));
if (file == null) {
throw 'No data file found';
}
var version =
file!.name!.split('-').elementAtOrNull(1)?.split('.').first;
file.name!.split('-').elementAtOrNull(1)?.split('.').first;
if (version != null && int.tryParse(version) != null) {
var currentVersion = appdata.settings['dataVersion'];
if (currentVersion != null && int.parse(version) <= currentVersion) {