diff --git a/Preferences/Preferences/SandboxPathBehaviorController.m b/Preferences/Preferences/SandboxPathBehaviorController.m index 498ab0b8c..ecf45482b 100644 --- a/Preferences/Preferences/SandboxPathBehaviorController.m +++ b/Preferences/Preferences/SandboxPathBehaviorController.m @@ -45,10 +45,27 @@ if(results && [results count] > 0) { for(SandboxToken *token in results) { + BOOL isDisconnected = NO; BOOL isStale = YES; NSError *err = nil; - NSURL *bookmarkUrl = [NSURL URLByResolvingBookmarkData:token.bookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:nil bookmarkDataIsStale:&isStale error:&err]; - [self addObject:@{ @"path": token.path, @"valid": ((!bookmarkUrl || isStale) ? NSLocalizedPrefString(@"ValidNo") : NSLocalizedPrefString(@"ValidYes")), @"isFolder": @(token.folder), @"token": token }]; + { + NSDictionary *dict = [NSURL resourceValuesForKeys:@[NSURLVolumeURLKey] fromBookmarkData:token.bookmark]; + if(dict) { + NSURL *volumeUrl = dict[NSURLVolumeURLKey]; + if(volumeUrl && [volumeUrl isFileURL] && [volumeUrl path]) { + if(![[NSFileManager defaultManager] fileExistsAtPath:[volumeUrl path]]) { + isDisconnected = YES; + } + } + } + } + + if(!isDisconnected) { + NSURL *bookmarkUrl = [NSURL URLByResolvingBookmarkData:token.bookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:nil bookmarkDataIsStale:&isStale error:&err]; + [self addObject:@{ @"path": token.path, @"valid": ((!bookmarkUrl || isStale) ? NSLocalizedPrefString(@"ValidNo") : NSLocalizedPrefString(@"ValidYes")), @"isFolder": @(token.folder), @"token": token }]; + } else { + [self addObject:@{ @"path": token.path, @"valid": NSLocalizedPrefString(@"ValidNo"), @"isFolder": @(token.folder), @"token": token }]; + } } } } diff --git a/Utils/SandboxBroker.m b/Utils/SandboxBroker.m index 570ffda19..42b4213d6 100644 --- a/Utils/SandboxBroker.m +++ b/Utils/SandboxBroker.m @@ -192,6 +192,18 @@ static SandboxBroker *kSharedSandboxBroker = nil; } }]; + if(ret) { + NSDictionary *dict = [NSURL resourceValuesForKeys:@[NSURLVolumeURLKey] fromBookmarkData:ret.token.bookmark]; + if(dict) { + NSURL *volumeUrl = dict[NSURLVolumeURLKey]; + if(volumeUrl && [volumeUrl isFileURL] && [volumeUrl path]) { + if(![[NSFileManager defaultManager] fileExistsAtPath:[volumeUrl path]]) { + return nil; + } + } + } + } + if(ret) { BOOL isStale; NSError *err = nil;