From a8f78d41fb97f3714849bed051055b7e916c934a Mon Sep 17 00:00:00 2001 From: Moustapha Kodjo Amadou <107993382+kodjodevf@users.noreply.github.com> Date: Wed, 12 Nov 2025 11:45:27 +0100 Subject: [PATCH] fix: update directory handling for macOS --- lib/main.dart | 10 +++++++++- lib/providers/storage_provider.dart | 10 +++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 4f44eaf7..26513862 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -101,7 +101,15 @@ Future _postLaunchInit(StorageProvider storage) async { Future _migrateOldLayout() async { if (!(Platform.isIOS || Platform.isMacOS)) return; final root = await getApplicationDocumentsDirectory(); - final oldRoot = Directory(p.join(root.path, 'Mangayomi')); + final rootM = Directory(p.join(root.path, 'Mangayomi')); + if (Platform.isIOS) { + await _migrateOld(rootM, root); + } else { + await _migrateOld(root, rootM); + } +} + +Future _migrateOld(Directory oldRoot, Directory root) async { if (!await oldRoot.exists()) return; final newDbDir = Directory(p.join(root.path, 'databases')); await newDbDir.create(recursive: true); diff --git a/lib/providers/storage_provider.dart b/lib/providers/storage_provider.dart index ed39c81d..9c6aac07 100644 --- a/lib/providers/storage_provider.dart +++ b/lib/providers/storage_provider.dart @@ -53,10 +53,10 @@ class StorageProvider { directory = Directory("/storage/emulated/0/Mangayomi/"); } else { final dir = await getApplicationDocumentsDirectory(); - // The documents dir in iOS and macOS is already named "Mangayomi". + // The documents dir in iOS is already named "Mangayomi". // Appending "Mangayomi" to the documents dir would create // unnecessarily nested Mangayomi/Mangayomi/ folder. - if (Platform.isIOS || Platform.isMacOS) return dir; + if (Platform.isIOS) return dir; directory = Directory(path.join(dir.path, 'Mangayomi')); } return directory; @@ -114,10 +114,10 @@ class StorageProvider { } else { final dir = await getApplicationDocumentsDirectory(); final p = dPath.isEmpty ? dir.path : dPath; - // The documents dir in iOS and macOS is already named "Mangayomi". + // The documents dir in iOS is already named "Mangayomi". // Appending "Mangayomi" to the documents dir would create // unnecessarily nested Mangayomi/Mangayomi/ folder. - if (Platform.isIOS || Platform.isMacOS) return Directory(p); + if (Platform.isIOS) return Directory(p); directory = Directory(path.join(p, 'Mangayomi')); } return directory; @@ -163,7 +163,7 @@ class StorageProvider { final dir = await getApplicationDocumentsDirectory(); String dbDir; if (Platform.isAndroid) return dir; - if (Platform.isIOS || Platform.isMacOS) { + if (Platform.isIOS) { // Put the database files inside /databases like on Windows, Linux // So they are not just in the app folders root dir dbDir = path.join(dir.path, 'databases');