diff --git a/SUDiskImageUnarchiver.m b/SUDiskImageUnarchiver.m index 7bc37b6a..80c83d29 100644 --- a/SUDiskImageUnarchiver.m +++ b/SUDiskImageUnarchiver.m @@ -65,15 +65,24 @@ mountedSuccessfully = YES; // Now that we've mounted it, we need to copy out its contents. - FSRef srcRef, dstRef; - OSStatus err; - err = FSPathMakeRef((UInt8 *)[mountPoint fileSystemRepresentation], &srcRef, NULL); - if (err != noErr) goto reportError; - err = FSPathMakeRef((UInt8 *)[[archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], &dstRef, NULL); - if (err != noErr) goto reportError; - - err = FSCopyObjectSync(&srcRef, &dstRef, (CFStringRef)mountPointName, NULL, kFSFileOperationSkipSourcePermissionErrors); - if (err != noErr) goto reportError; + if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) { + // On 10.6 and later we don't want to use the File Manager API and instead want to use NSFileManager (fixes #827357). + NSFileManager *manager = [[NSFileManager alloc] init]; + if (![manager copyItemAtPath:mountPoint toPath:[archivePath stringByDeletingLastPathComponent] error:NULL]) { + goto reportError; + } + } + else { + FSRef srcRef, dstRef; + OSStatus err; + err = FSPathMakeRef((UInt8 *)[mountPoint fileSystemRepresentation], &srcRef, NULL); + if (err != noErr) goto reportError; + err = FSPathMakeRef((UInt8 *)[[archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], &dstRef, NULL); + if (err != noErr) goto reportError; + + err = FSCopyObjectSync(&srcRef, &dstRef, (CFStringRef)mountPointName, NULL, kFSFileOperationSkipSourcePermissionErrors); + if (err != noErr) goto reportError; + } [self performSelectorOnMainThread:@selector(notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO]; goto finally; diff --git a/SUPlainInstallerInternals.m b/SUPlainInstallerInternals.m index bdde4581..630ad663 100644 --- a/SUPlainInstallerInternals.m +++ b/SUPlainInstallerInternals.m @@ -461,26 +461,58 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza err = FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL); if (err == noErr && hadFileAtDest) - { - err = FSMoveObjectSync(&dstRef, &tmpDirRef, (CFStringRef)[tmpPath lastPathComponent], &movedRef, 0); - } - if (err != noErr && hadFileAtDest) - { - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]]; - return NO; + { + if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) + { + NSFileManager *manager = [[NSFileManager alloc] init]; + BOOL success = [manager moveItemAtPath:dst toPath:tmpPath error:error]; + if (!success && hadFileAtDest) + { + if (error != NULL) + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]]; + return NO; + } + + } else { + err = FSMoveObjectSync(&dstRef, &tmpDirRef, (CFStringRef)[tmpPath lastPathComponent], &movedRef, 0); + if (err != noErr && hadFileAtDest) + { + if (error != NULL) + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]]; + return NO; + } + } } + err = FSPathMakeRef((UInt8 *)[src fileSystemRepresentation], &srcRef, NULL); if (err == noErr) - err = FSCopyObjectSync(&srcRef, &dstDirRef, (CFStringRef)[dst lastPathComponent], NULL, 0); - if (err != noErr) { - // We better move the old version back to its old location - if( hadFileAtDest ) - FSMoveObjectSync(&movedRef, &dstDirRef, (CFStringRef)[dst lastPathComponent], &movedRef, 0); - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't copy %@ to %@.", src, dst] forKey:NSLocalizedDescriptionKey]]; - return NO; + if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) + { + NSFileManager *manager = [[NSFileManager alloc] init]; + BOOL success = [manager copyItemAtPath:src toPath:dst error:error]; + if (!success) + { + // We better move the old version back to its old location + if( hadFileAtDest ) + success = [manager moveItemAtPath:tmpPath toPath:dst error:error]; + if (error != NULL) + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]]; + return NO; + + } + } else { + err = FSCopyObjectSync(&srcRef, &dstDirRef, (CFStringRef)[dst lastPathComponent], NULL, 0); + if (err != noErr) + { + // We better move the old version back to its old location + if( hadFileAtDest ) + FSMoveObjectSync(&movedRef, &dstDirRef, (CFStringRef)[dst lastPathComponent], &movedRef, 0); + if (error != NULL) + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't copy %@ to %@.", src, dst] forKey:NSLocalizedDescriptionKey]]; + return NO; + } + } } // If the currently-running application is trusted, the new