diff options
author | Jocelyn Turcotte <jturcotte@woboq.com> | 2016-01-14 18:24:29 +0300 |
---|---|---|
committer | Jocelyn Turcotte <jturcotte@woboq.com> | 2016-01-14 18:25:19 +0300 |
commit | 439eddb5234e132eba311361841bd1125c794d1b (patch) | |
tree | 9cad98bf3d04752c6f62bf8220308a3ee7dca782 /shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt | |
parent | 7beb6f223449eca5026c670e129a878e9619c37f (diff) |
OS X shell: Don't allow sharing sync roots #3505
Diffstat (limited to 'shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt')
-rw-r--r-- | shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.h | 1 | ||||
-rw-r--r-- | shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.m | 20 |
2 files changed, 19 insertions, 2 deletions
diff --git a/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.h b/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.h index 749f84931..a1356045b 100644 --- a/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.h +++ b/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.h @@ -21,7 +21,6 @@ { SyncClientProxy *_syncClientProxy; NSMutableSet *_registeredDirectories; - NSMutableSet *_requestedUrls; NSString *_shareMenuTitle; } diff --git a/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.m b/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.m index 6273b5032..440af7e33 100644 --- a/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.m +++ b/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.m @@ -83,7 +83,25 @@ - (NSMenu *)menuForMenuKind:(FIMenuKind)whichMenu { - if (_shareMenuTitle) { + FIFinderSyncController *syncController = [FIFinderSyncController defaultController]; + NSMutableSet *rootPaths = [[NSMutableSet alloc] init]; + [syncController.directoryURLs enumerateObjectsUsingBlock: ^(id obj, BOOL *stop) { + [rootPaths addObject:[obj path]]; + }]; + + // The server doesn't support sharing a root directory so do not show the option in this case. + // It is still possible to get a problematic sharing by selecting both the root and a child, + // but this is so complicated to do and meaningless that it's not worth putting this check + // also in shareMenuAction. + __block BOOL onlyRootsSelected = YES; + [syncController.selectedItemURLs enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) { + if (![rootPaths member:[obj path]]) { + onlyRootsSelected = NO; + *stop = YES; + } + }]; + + if (_shareMenuTitle && !onlyRootsSelected) { NSMenu *menu = [[NSMenu alloc] initWithTitle:@""]; [menu addItemWithTitle:_shareMenuTitle action:@selector(shareMenuAction:) keyEquivalent:@"title"]; |