From 93f7f72d07f54142df0169cf25630b3df404e64f Mon Sep 17 00:00:00 2001 From: nyne Date: Tue, 17 Jun 2025 17:15:35 +0800 Subject: [PATCH] Fixed some issues when using custom download path on Android. Close #400 --- lib/foundation/local.dart | 2 ++ lib/utils/pdf.dart | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib/foundation/local.dart b/lib/foundation/local.dart index 812d6eb..eee529f 100644 --- a/lib/foundation/local.dart +++ b/lib/foundation/local.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'dart:isolate'; import 'package:flutter/widgets.dart' show ChangeNotifier; +import 'package:flutter_saf/flutter_saf.dart'; import 'package:path_provider/path_provider.dart'; import 'package:sqlite3/sqlite3.dart'; import 'package:venera/foundation/comic_source/comic_source.dart'; @@ -625,6 +626,7 @@ class LocalManager with ChangeNotifier { /// Deletes the directories in a separate isolate to avoid blocking the UI thread. static void _deleteDirectories(List directories) { Isolate.run(() async { + await SAFTaskWorker().init(); for (var dir in directories) { try { if (dir.existsSync()) { diff --git a/lib/utils/pdf.dart b/lib/utils/pdf.dart index 48da584..9e3f8ee 100644 --- a/lib/utils/pdf.dart +++ b/lib/utils/pdf.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:isolate'; +import 'package:flutter_saf/flutter_saf.dart'; import 'package:venera/foundation/app.dart'; import 'package:venera/foundation/local.dart'; import 'package:venera/utils/image.dart'; @@ -74,6 +75,9 @@ Future _runIsolate( return Isolate.spawn( (sendPort) => overrideIO( () async { + if (App.isAndroid) { + await SAFTaskWorker().init(); + } var receivePort = ReceivePort(); sendPort.send(receivePort.sendPort);