mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
improve code
This commit is contained in:
@@ -324,7 +324,7 @@ class DownloadManager {
|
|||||||
where illust_id = ?;
|
where illust_id = ?;
|
||||||
''', [illust.illustId]);
|
''', [illust.illustId]);
|
||||||
for(var image in images) {
|
for(var image in images) {
|
||||||
File(image["path"] as String).deleteIfExists();
|
File(image["path"] as String).deleteIgnoreError();
|
||||||
}
|
}
|
||||||
_db.execute('''
|
_db.execute('''
|
||||||
delete from images
|
delete from images
|
||||||
|
@@ -12,6 +12,14 @@ extension FSExt on FileSystemEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> deleteIgnoreError() async {
|
||||||
|
try {
|
||||||
|
await delete();
|
||||||
|
} catch (e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int get size {
|
int get size {
|
||||||
if (this is File) {
|
if (this is File) {
|
||||||
return (this as File).lengthSync();
|
return (this as File).lengthSync();
|
||||||
|
@@ -8,8 +8,14 @@ import 'package:url_launcher/url_launcher_string.dart';
|
|||||||
Future<String> getLatestVersion() async {
|
Future<String> getLatestVersion() async {
|
||||||
var dio = AppDio();
|
var dio = AppDio();
|
||||||
var res = await dio
|
var res = await dio
|
||||||
.get("https://api.github.com/repos/wgh136/pixes/releases/latest");
|
.get("https://raw.githubusercontent.com/wgh136/pixes/refs/heads/master/pubspec.yaml");
|
||||||
return (res.data["tag_name"] as String).replaceFirst("v", "");
|
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.
|
/// Compare two versions.
|
||||||
|
Reference in New Issue
Block a user