Revision: 7500
http://skim-app.svn.sourceforge.net/skim-app/?rev=7500&view=rev
Author: hofman
Date: 2011-09-21 15:16:35 +0000 (Wed, 21 Sep 2011)
Log Message:
-----------
only do copy from dmg on main thread on 10.4
Modified Paths:
--------------
trunk/vendorsrc/andymatuschak/Sparkle/SUDiskImageUnarchiver.m
Modified: trunk/vendorsrc/andymatuschak/Sparkle/SUDiskImageUnarchiver.m
===================================================================
--- trunk/vendorsrc/andymatuschak/Sparkle/SUDiskImageUnarchiver.m
2011-09-21 15:03:01 UTC (rev 7499)
+++ trunk/vendorsrc/andymatuschak/Sparkle/SUDiskImageUnarchiver.m
2011-09-21 15:16:35 UTC (rev 7500)
@@ -17,46 +17,17 @@
return [[path pathExtension] isEqualToString:@"dmg"];
}
-- (void)_extractDMG
+- (void)_extractDMGContentFromPath:(NSString *)mountPoint
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- BOOL mountedSuccessfully = NO;
-
// get a local copy of NSFileManager because this is running from a
secondary thread
NSFileManager *fm;
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4)
fm = [[[NSFileManager alloc] init] autorelease];
else
fm = [NSFileManager defaultManager];
-
- // get a unique mount point path
- NSString *mountPointName = nil;
- NSString *mountPoint = nil;
- do
- {
- CFUUIDRef uuid = CFUUIDCreate(NULL);
- mountPointName = (NSString *)CFUUIDCreateString(NULL, uuid);
- CFRelease(uuid);
-#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4
- [NSMakeCollectable((CFStringRef)mountPointName) autorelease];
-#else
- [mountPointName autorelease];
-#endif
- mountPoint = [@"/Volumes"
stringByAppendingPathComponent:mountPointName];
- }
- while ([fm fileExistsAtPath:mountPoint]);
- NSArray* arguments = [NSArray arrayWithObjects:@"attach", archivePath,
@"-mountpoint", mountPoint, @"-noverify", @"-nobrowse", @"-noautoopen", nil];
- // set up a pipe and push "yes" (y works too), this will accept any
license agreement crap
- // not every .dmg needs this, but this will make sure it works with
everyone
- NSData* yesData = [[[NSData alloc] initWithBytes:"yes\n" length:4]
autorelease];
-
- NSData *result = [NTSynchronousTask task:@"/usr/bin/hdiutil"
directory:@"/" withArgs:arguments input:yesData];
- if (!result) goto reportError;
- mountedSuccessfully = YES;
-
// Now that we've mounted it, we need to copy out its contents.
- NSString *targetPath = [[archivePath stringByDeletingLastPathComponent]
stringByAppendingPathComponent:mountPointName];
+ NSString *targetPath = [[archivePath stringByDeletingLastPathComponent]
stringByAppendingPathComponent:[mountPoint lastPathComponent]];
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4
if (![fm createDirectoryAtPath:targetPath withIntermediateDirectories:YES
attributes:nil error:NULL])
#else
@@ -92,19 +63,58 @@
[self performSelectorOnMainThread:@selector(_notifyDelegateOfFailure)
withObject:nil waitUntilDone:NO];
finally:
- if (mountedSuccessfully)
- [NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil"
arguments:[NSArray arrayWithObjects:@"detach", mountPoint, @"-force", nil]];
- [pool drain];
+ [NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray
arrayWithObjects:@"detach", mountPoint, @"-force", nil]];
}
-- (void)start
-{
+- (void)_extractDMG
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ // get a local copy of NSFileManager because this is running from a
secondary thread
+ NSFileManager *fm;
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4)
- [NSThread detachNewThreadSelector:@selector(_extractDMG) toTarget:self
withObject:nil];
+ fm = [[[NSFileManager alloc] init] autorelease];
else
- [self _extractDMG];
+ fm = [NSFileManager defaultManager];
+
+ // get a unique mount point path
+ NSString *mountPointName = nil;
+ NSString *mountPoint = nil;
+ do
+ {
+ CFUUIDRef uuid = CFUUIDCreate(NULL);
+ mountPointName = (NSString *)CFUUIDCreateString(NULL, uuid);
+ CFRelease(uuid);
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4
+ [NSMakeCollectable((CFStringRef)mountPointName) autorelease];
+#else
+ [mountPointName autorelease];
+#endif
+ mountPoint = [@"/Volumes"
stringByAppendingPathComponent:mountPointName];
+ }
+ while ([fm fileExistsAtPath:mountPoint]);
+
+ NSArray* arguments = [NSArray arrayWithObjects:@"attach", archivePath,
@"-mountpoint", mountPoint, @"-noverify", @"-nobrowse", @"-noautoopen", nil];
+ // set up a pipe and push "yes" (y works too), this will accept any
license agreement crap
+ // not every .dmg needs this, but this will make sure it works with
everyone
+ NSData* yesData = [[[NSData alloc] initWithBytes:"yes\n" length:4]
autorelease];
+
+ NSData *result = [NTSynchronousTask task:@"/usr/bin/hdiutil"
directory:@"/" withArgs:arguments input:yesData];
+ if (!result)
+ [self performSelectorOnMainThread:@selector(_notifyDelegateOfFailure)
withObject:nil waitUntilDone:NO];
+ else if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4)
+ [self _extractDMGContentFromPath:mountPoint];
+ else
+ [self
performSelectorOnMainThread:@selector(_extractDMGContentFromPath:)
withObject:mountPoint waitUntilDone:NO];
+
+ [pool drain];
}
+- (void)start
+{
+ [NSThread detachNewThreadSelector:@selector(_extractDMG) toTarget:self
withObject:nil];
+}
+
+ (void)load
{
[self _registerImplementation:self];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit