Sandbox: Invalidate dead network shares faster
This should solve the endless waiting people were experiencing. Fixes #392 Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
7774c17efa
commit
41780e88d0
2 changed files with 31 additions and 2 deletions
|
@ -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 }];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue