[Sandbox] Handle file tree path config better

Handle the configuration better, by adding the path to the grants list
if it is newly configured.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
swiftingly
Christopher Snowhill 2022-06-29 00:31:34 -07:00
parent 29c070a616
commit 1a4c140708
3 changed files with 5 additions and 1 deletions

View File

@ -20,6 +20,8 @@
} }
- (void)updatePath { - (void)updatePath {
if(!url) return;
NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtURL:url NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtURL:url
includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey] includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey]
options:(NSDirectoryEnumerationSkipsSubdirectoryDescendants | NSDirectoryEnumerationSkipsPackageDescendants | NSDirectoryEnumerationSkipsHiddenFiles) options:(NSDirectoryEnumerationSkipsSubdirectoryDescendants | NSDirectoryEnumerationSkipsPackageDescendants | NSDirectoryEnumerationSkipsHiddenFiles)

View File

@ -74,7 +74,7 @@ static NSURL *defaultMusicDirectory(void) {
DLog(@"File tree root URL: %@\n", url); DLog(@"File tree root URL: %@\n", url);
NSURL *newURL = [NSURL URLWithString:url]; NSURL *newURL = [NSURL URLWithString:url];
if((!self.rootURL || ![self.rootURL isEqualTo:newURL]) && ![[SandboxBroker sharedSandboxBroker] areAllPathsSafe:@[newURL]]) { if((!self.rootURL || ![self.rootURL isEqualTo:newURL]) && ![[SandboxBroker sharedSandboxBroker] areAllPathsSafe:@[newURL]]) {
[AppController globalShowPathSuggester]; [[SandboxBroker sharedSandboxBroker] addFolderIfMissing:newURL];
} }
self.rootURL = newURL; self.rootURL = newURL;
} }

View File

@ -44,6 +44,8 @@ const FSEventStreamEventId eventIds[]) {
- (void)setPath:(NSString *)path { - (void)setPath:(NSString *)path {
[self cleanUp]; [self cleanUp];
if(!path) return;
// Create FSEvent stream // Create FSEvent stream
NSArray *pathsToWatch = @[path]; NSArray *pathsToWatch = @[path];