From 9f67cd0d075bb7d69de2deeb00727bf504d0ab6c Mon Sep 17 00:00:00 2001 From: nyne Date: Sat, 21 Dec 2024 17:51:54 +0800 Subject: [PATCH] fix #110 --- lib/foundation/local.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/foundation/local.dart b/lib/foundation/local.dart index b1d0601..7dd6efa 100644 --- a/lib/foundation/local.dart +++ b/lib/foundation/local.dart @@ -153,6 +153,15 @@ class LocalManager with ChangeNotifier { Directory get directory => Directory(path); + void _checkNoMedia() { + if (App.isAndroid) { + var file = File(FilePath.join(path, '.nomedia')); + if (!file.existsSync()) { + file.createSync(); + } + } + } + // return error message if failed Future setNewPath(String newPath) async { var newDir = Directory(newPath); @@ -174,6 +183,7 @@ class LocalManager with ChangeNotifier { } await directory.deleteContents(recursive: true); path = newPath; + _checkNoMedia(); return null; } @@ -233,6 +243,7 @@ class LocalManager with ChangeNotifier { catch(e, s) { Log.error("IO", "Failed to create local folder: $e", s); } + _checkNoMedia(); restoreDownloadingTasks(); }