Permalink
Browse files

Fixes 246805

Sparkle no longer calls it a critical failure if it can't read a file on a DMG (like for .Trashes).
  • Loading branch information...
andymatuschak committed Jul 9, 2008
1 parent 660228f commit dc249c1ec50f7f1c4f8f94b6a4da1f98ee237736
Showing with 8 additions and 4 deletions.
  1. +8 −4 SUDiskImageUnarchiver.m
View
@@ -29,8 +29,7 @@ - (void)_extractDMG
BOOL mountedSuccessfully = NO;
// get a unique mount point path
- NSString *mountPrefix = [@"/Volumes" stringByAppendingPathComponent:[[archivePath lastPathComponent] stringByDeletingPathExtension]];
- NSString *mountPoint = [mountPrefix stringByAppendingString:[[NSProcessInfo processInfo] globallyUniqueString]];
+ NSString *mountPoint = [@"/Volumes" stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]];
if ([[NSFileManager defaultManager] fileExistsAtPath:mountPoint]) goto reportError;
@@ -55,7 +54,10 @@ - (void)_extractDMG
id subpathEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath:mountPoint] objectEnumerator], currentSubpath;
while ((currentSubpath = [subpathEnumerator nextObject]))
{
- if (![[NSFileManager defaultManager] copyPath:[mountPoint stringByAppendingPathComponent:currentSubpath] toPath:[targetPath stringByAppendingPathComponent:currentSubpath] handler:nil])
+ NSString *currentFullPath = [mountPoint stringByAppendingPathComponent:currentSubpath];
+ // Don't bother trying (and failing) to copy out files we can't read. That's not going to be the app anyway.
+ if (![[NSFileManager defaultManager] isReadableFileAtPath:currentFullPath]) continue;
+ if (![[NSFileManager defaultManager] copyPath:currentFullPath toPath:[targetPath stringByAppendingPathComponent:currentSubpath] handler:nil])
goto reportError;
}
@@ -67,7 +69,9 @@ - (void)_extractDMG
finally:
if (mountedSuccessfully)
- [NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray arrayWithObjects:@"detach", mountPoint, @"-force", nil]];
+ [NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray arrayWithObjects:@"detach", mountPoint, @"-force", nil]];
+ else
+ [[NSFileManager defaultManager] removeFileAtPath:mountPoint handler:nil];
[pool drain];
}

0 comments on commit dc249c1

Please sign in to comment.