From 3ef6a4204f64c996235d442764a1acbe77893ad2 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 29 Jun 2022 00:31:34 -0700 Subject: [PATCH] [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 --- FileTree/DirectoryNode.m | 2 ++ FileTree/FileTreeDataSource.m | 2 +- FileTree/PathWatcher.m | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/FileTree/DirectoryNode.m b/FileTree/DirectoryNode.m index ba2f7bec8..4dbab8de4 100644 --- a/FileTree/DirectoryNode.m +++ b/FileTree/DirectoryNode.m @@ -20,6 +20,8 @@ } - (void)updatePath { + if(!url) return; + NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtURL:url includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey] options:(NSDirectoryEnumerationSkipsSubdirectoryDescendants | NSDirectoryEnumerationSkipsPackageDescendants | NSDirectoryEnumerationSkipsHiddenFiles) diff --git a/FileTree/FileTreeDataSource.m b/FileTree/FileTreeDataSource.m index 5cd0b9efd..a4db38512 100644 --- a/FileTree/FileTreeDataSource.m +++ b/FileTree/FileTreeDataSource.m @@ -74,7 +74,7 @@ static NSURL *defaultMusicDirectory(void) { DLog(@"File tree root URL: %@\n", url); NSURL *newURL = [NSURL URLWithString:url]; if((!self.rootURL || ![self.rootURL isEqualTo:newURL]) && ![[SandboxBroker sharedSandboxBroker] areAllPathsSafe:@[newURL]]) { - [AppController globalShowPathSuggester]; + [[SandboxBroker sharedSandboxBroker] addFolderIfMissing:newURL]; } self.rootURL = newURL; } diff --git a/FileTree/PathWatcher.m b/FileTree/PathWatcher.m index de2ff6963..ee02d30e3 100644 --- a/FileTree/PathWatcher.m +++ b/FileTree/PathWatcher.m @@ -44,6 +44,8 @@ const FSEventStreamEventId eventIds[]) { - (void)setPath:(NSString *)path { [self cleanUp]; + if(!path) return; + // Create FSEvent stream NSArray *pathsToWatch = @[path];