diff --git a/lib/network/download.dart b/lib/network/download.dart index 2f17287..f0d41b2 100644 --- a/lib/network/download.dart +++ b/lib/network/download.dart @@ -324,7 +324,7 @@ class DownloadManager { where illust_id = ?; ''', [illust.illustId]); for(var image in images) { - File(image["path"] as String).deleteIfExists(); + File(image["path"] as String).deleteIgnoreError(); } _db.execute(''' delete from images diff --git a/lib/utils/io.dart b/lib/utils/io.dart index 3624348..2ee6725 100644 --- a/lib/utils/io.dart +++ b/lib/utils/io.dart @@ -12,6 +12,14 @@ extension FSExt on FileSystemEntity { } } + Future deleteIgnoreError() async { + try { + await delete(); + } catch (e) { + // ignore + } + } + int get size { if (this is File) { return (this as File).lengthSync(); diff --git a/lib/utils/update.dart b/lib/utils/update.dart index 0a936d3..e0b3d3d 100644 --- a/lib/utils/update.dart +++ b/lib/utils/update.dart @@ -8,8 +8,14 @@ import 'package:url_launcher/url_launcher_string.dart'; Future getLatestVersion() async { var dio = AppDio(); var res = await dio - .get("https://api.github.com/repos/wgh136/pixes/releases/latest"); - return (res.data["tag_name"] as String).replaceFirst("v", ""); + .get("https://raw.githubusercontent.com/wgh136/pixes/refs/heads/master/pubspec.yaml"); + var lines = (res.data as String).split("\n"); + for (var line in lines) { + if (line.startsWith("version:")) { + return line.split(":")[1].split('+')[0].trim(); + } + } + throw "Failed to get latest version"; } /// Compare two versions.