Skip to content

Commit 23385d8

Browse files
authored
fix: macOS folder permissions (#435)
1 parent 9daf183 commit 23385d8

4 files changed

Lines changed: 81 additions & 43 deletions

File tree

lib/providers/sync_provider.dart

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -265,36 +265,44 @@ class SyncNotifier extends StateNotifier<SyncSettingsModel> {
265265
}
266266

267267
Future<void> addSyncItem(BuildContext? context, ItemBaseModel item) async {
268-
if (context == null) return;
269-
270-
if (saveDirectory == null) {
271-
String? selectedDirectory =
272-
await FilePicker.platform.getDirectoryPath(dialogTitle: context.localized.syncSelectDownloadsFolder);
273-
if (selectedDirectory?.isEmpty == true && context.mounted) {
274-
fladderSnackbar(context, title: context.localized.syncNoFolderSetup);
275-
return;
268+
try {
269+
if (context == null) return;
270+
271+
if (saveDirectory == null) {
272+
String? selectedDirectory =
273+
await FilePicker.platform.getDirectoryPath(dialogTitle: context.localized.syncSelectDownloadsFolder);
274+
if (selectedDirectory?.isEmpty == true && context.mounted) {
275+
fladderSnackbar(context, title: context.localized.syncNoFolderSetup);
276+
return;
277+
}
278+
ref.read(clientSettingsProvider.notifier).setSyncPath(selectedDirectory);
276279
}
277-
ref.read(clientSettingsProvider.notifier).setSyncPath(selectedDirectory);
278-
}
279280

280-
if (context.mounted) {
281-
fladderSnackbar(context, title: context.localized.syncAddItemForSyncing(item.detailedName(context) ?? "Unknown"));
282-
}
283-
final newSync = switch (item) {
284-
EpisodeModel episode => await syncSeries(item.parentBaseModel, episode: episode),
285-
SeasonModel season => await syncSeries(item.parentBaseModel, season: season),
286-
SeriesModel series => await syncSeries(series),
287-
MovieModel movie => await syncMovie(movie),
288-
_ => null
289-
};
290-
if (context.mounted) {
291-
fladderSnackbar(context,
292-
title: newSync != null
293-
? context.localized.startedSyncingItem(item.detailedName(context) ?? "Unknown")
294-
: context.localized.unableToSyncItem(item.detailedName(context) ?? "Unknown"));
295-
}
281+
if (context.mounted) {
282+
fladderSnackbar(context,
283+
title: context.localized.syncAddItemForSyncing(item.detailedName(context) ?? "Unknown"));
284+
}
285+
final newSync = switch (item) {
286+
EpisodeModel episode => await syncSeries(item.parentBaseModel, episode: episode),
287+
SeasonModel season => await syncSeries(item.parentBaseModel, season: season),
288+
SeriesModel series => await syncSeries(series),
289+
MovieModel movie => await syncMovie(movie),
290+
_ => null
291+
};
292+
if (context.mounted) {
293+
fladderSnackbar(context,
294+
title: newSync != null
295+
? context.localized.startedSyncingItem(item.detailedName(context) ?? "Unknown")
296+
: context.localized.unableToSyncItem(item.detailedName(context) ?? "Unknown"));
297+
}
296298

297-
return;
299+
return;
300+
} catch (e) {
301+
log('Error adding sync item: ${e.toString()}');
302+
if (context?.mounted == true) {
303+
fladderSnackbar(context!, title: context.localized.somethingWentWrong);
304+
}
305+
}
298306
}
299307

300308
void viewDatabase(BuildContext context) =>

macos/Runner/AppDelegate.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ class AppDelegate: FlutterAppDelegate {
66
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
77
return true
88
}
9+
10+
override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
11+
return true
12+
}
913
}
Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
4-
<dict>
5-
<key>com.apple.security.app-sandbox</key>
6-
<true/>
7-
<key>com.apple.security.cs.allow-jit</key>
8-
<true/>
9-
<key>com.apple.security.network.server</key>
10-
<true/>
11-
<key>com.apple.security.network.client</key>
12-
<true/>
13-
</dict>
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.assets.movies.read-write</key>
8+
<true/>
9+
<key>com.apple.security.assets.music.read-write</key>
10+
<true/>
11+
<key>com.apple.security.assets.pictures.read-write</key>
12+
<true/>
13+
<key>com.apple.security.cs.allow-jit</key>
14+
<true/>
15+
<key>com.apple.security.files.downloads.read-write</key>
16+
<true/>
17+
<key>com.apple.security.files.user-selected.read-write</key>
18+
<true/>
19+
<key>com.apple.security.network.client</key>
20+
<true/>
21+
<key>com.apple.security.network.server</key>
22+
<true/>
23+
<key>com.apple.security.personal-information.location</key>
24+
<true/>
25+
</dict>
1426
</plist>

macos/Runner/Release.entitlements

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
4-
<dict>
5-
<key>com.apple.security.app-sandbox</key>
6-
<true/>
7-
<key>com.apple.security.network.client</key>
8-
<true/>
9-
</dict>
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.assets.movies.read-write</key>
8+
<true/>
9+
<key>com.apple.security.assets.music.read-write</key>
10+
<true/>
11+
<key>com.apple.security.assets.pictures.read-write</key>
12+
<true/>
13+
<key>com.apple.security.files.downloads.read-write</key>
14+
<true/>
15+
<key>com.apple.security.files.user-selected.read-write</key>
16+
<true/>
17+
<key>com.apple.security.network.client</key>
18+
<true/>
19+
<key>com.apple.security.network.server</key>
20+
<true/>
21+
<key>com.apple.security.personal-information.location</key>
22+
<true/>
23+
</dict>
1024
</plist>

0 commit comments

Comments
 (0)