From 0e22574002351db325104011b82864c758c78d62 Mon Sep 17 00:00:00 2001 From: nyne Date: Sun, 22 Dec 2024 11:22:59 +0800 Subject: [PATCH] fix #111 --- lib/foundation/local.dart | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/foundation/local.dart b/lib/foundation/local.dart index 7dd6efa..43dcab8 100644 --- a/lib/foundation/local.dart +++ b/lib/foundation/local.dart @@ -462,13 +462,19 @@ class LocalManager with ChangeNotifier { void restoreDownloadingTasks() { var file = File(FilePath.join(App.dataPath, 'downloading_tasks.json')); if (file.existsSync()) { - var tasks = jsonDecode(file.readAsStringSync()); - for (var e in tasks) { - var task = DownloadTask.fromJson(e); - if (task != null) { - downloadingTasks.add(task); + try { + var tasks = jsonDecode(file.readAsStringSync()); + for (var e in tasks) { + var task = DownloadTask.fromJson(e); + if (task != null) { + downloadingTasks.add(task); + } } } + catch(e) { + file.delete(); + Log.error("LocalManager", "Failed to restore downloading tasks: $e"); + } } }