From 23385d8e62ac9c358e176a22a02f7779bd020c67 Mon Sep 17 00:00:00 2001 From: PartyDonut <42371342+PartyDonut@users.noreply.github.com> Date: Mon, 4 Aug 2025 16:37:38 +0200 Subject: [PATCH] fix: macOS folder permissions (#435) --- lib/providers/sync_provider.dart | 60 +++++++++++++++----------- macos/Runner/AppDelegate.swift | 4 ++ macos/Runner/DebugProfile.entitlements | 32 +++++++++----- macos/Runner/Release.entitlements | 26 ++++++++--- 4 files changed, 80 insertions(+), 42 deletions(-) diff --git a/lib/providers/sync_provider.dart b/lib/providers/sync_provider.dart index 4b1800c..031897e 100644 --- a/lib/providers/sync_provider.dart +++ b/lib/providers/sync_provider.dart @@ -265,36 +265,44 @@ class SyncNotifier extends StateNotifier { } Future addSyncItem(BuildContext? context, ItemBaseModel item) async { - if (context == null) return; + try { + if (context == null) return; - if (saveDirectory == null) { - String? selectedDirectory = - await FilePicker.platform.getDirectoryPath(dialogTitle: context.localized.syncSelectDownloadsFolder); - if (selectedDirectory?.isEmpty == true && context.mounted) { - fladderSnackbar(context, title: context.localized.syncNoFolderSetup); - return; + if (saveDirectory == null) { + String? selectedDirectory = + await FilePicker.platform.getDirectoryPath(dialogTitle: context.localized.syncSelectDownloadsFolder); + if (selectedDirectory?.isEmpty == true && context.mounted) { + fladderSnackbar(context, title: context.localized.syncNoFolderSetup); + return; + } + ref.read(clientSettingsProvider.notifier).setSyncPath(selectedDirectory); } - ref.read(clientSettingsProvider.notifier).setSyncPath(selectedDirectory); - } - if (context.mounted) { - fladderSnackbar(context, title: context.localized.syncAddItemForSyncing(item.detailedName(context) ?? "Unknown")); - } - final newSync = switch (item) { - EpisodeModel episode => await syncSeries(item.parentBaseModel, episode: episode), - SeasonModel season => await syncSeries(item.parentBaseModel, season: season), - SeriesModel series => await syncSeries(series), - MovieModel movie => await syncMovie(movie), - _ => null - }; - if (context.mounted) { - fladderSnackbar(context, - title: newSync != null - ? context.localized.startedSyncingItem(item.detailedName(context) ?? "Unknown") - : context.localized.unableToSyncItem(item.detailedName(context) ?? "Unknown")); - } + if (context.mounted) { + fladderSnackbar(context, + title: context.localized.syncAddItemForSyncing(item.detailedName(context) ?? "Unknown")); + } + final newSync = switch (item) { + EpisodeModel episode => await syncSeries(item.parentBaseModel, episode: episode), + SeasonModel season => await syncSeries(item.parentBaseModel, season: season), + SeriesModel series => await syncSeries(series), + MovieModel movie => await syncMovie(movie), + _ => null + }; + if (context.mounted) { + fladderSnackbar(context, + title: newSync != null + ? context.localized.startedSyncingItem(item.detailedName(context) ?? "Unknown") + : context.localized.unableToSyncItem(item.detailedName(context) ?? "Unknown")); + } - return; + return; + } catch (e) { + log('Error adding sync item: ${e.toString()}'); + if (context?.mounted == true) { + fladderSnackbar(context!, title: context.localized.somethingWentWrong); + } + } } void viewDatabase(BuildContext context) => diff --git a/macos/Runner/AppDelegate.swift b/macos/Runner/AppDelegate.swift index 8e02df2..b3c1761 100644 --- a/macos/Runner/AppDelegate.swift +++ b/macos/Runner/AppDelegate.swift @@ -6,4 +6,8 @@ class AppDelegate: FlutterAppDelegate { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } } diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements index 867a0ba..5be18df 100644 --- a/macos/Runner/DebugProfile.entitlements +++ b/macos/Runner/DebugProfile.entitlements @@ -1,14 +1,26 @@ - - com.apple.security.app-sandbox - - com.apple.security.cs.allow-jit - - com.apple.security.network.server - - com.apple.security.network.client - - + + com.apple.security.app-sandbox + + com.apple.security.assets.movies.read-write + + com.apple.security.assets.music.read-write + + com.apple.security.assets.pictures.read-write + + com.apple.security.cs.allow-jit + + com.apple.security.files.downloads.read-write + + com.apple.security.files.user-selected.read-write + + com.apple.security.network.client + + com.apple.security.network.server + + com.apple.security.personal-information.location + + diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements index a68a6a2..c61c9ed 100644 --- a/macos/Runner/Release.entitlements +++ b/macos/Runner/Release.entitlements @@ -1,10 +1,24 @@ - - com.apple.security.app-sandbox - - com.apple.security.network.client - - + + com.apple.security.app-sandbox + + com.apple.security.assets.movies.read-write + + com.apple.security.assets.music.read-write + + com.apple.security.assets.pictures.read-write + + com.apple.security.files.downloads.read-write + + com.apple.security.files.user-selected.read-write + + com.apple.security.network.client + + com.apple.security.network.server + + com.apple.security.personal-information.location + +