mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Merge branch 'master' into quiet-automatic-update
This commit is contained in:
commit
716bb30e7c
5 files changed
+121
-41
No files matched your search
+10
-1
@@ -163,8 +163,17 @@
|
||||
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]] retain];
|
||||
}
|
||||
|
||||
// Create the temporary directory if necessary.
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
|
||||
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir attributes:nil];
|
||||
BOOL success = YES;
|
||||
NSEnumerator *pathComponentEnumerator = [[tempDir pathComponents] objectEnumerator];
|
||||
NSString *pathComponentAccumulator = @"";
|
||||
NSString *currentPathComponent;
|
||||
while ((currentPathComponent = [pathComponentEnumerator nextObject])) {
|
||||
pathComponentAccumulator = [pathComponentAccumulator stringByAppendingPathComponent:currentPathComponent];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:pathComponentAccumulator]) continue;
|
||||
success &= [[NSFileManager defaultManager] createDirectoryAtPath:pathComponentAccumulator attributes:nil];
|
||||
}
|
||||
#else
|
||||
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -15,11 +15,11 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Turn off DSA signature check (practically invites man-in-the-middle attacks):
|
||||
#define ENDANGER_USERS_WITH_INSECURE_UPDATES 1
|
||||
#define ENDANGER_USERS_WITH_INSECURE_UPDATES 0
|
||||
|
||||
// Sparkle usually doesn't allow downgrades as they're usually accidental, but
|
||||
// if your app has a downgrade function or URL handler, turn this on:
|
||||
#define PERMIT_AUTOMATED_DOWNGRADES 1
|
||||
#define PERMIT_AUTOMATED_DOWNGRADES 0
|
||||
|
||||
// If your app file on disk is named "MyApp 1.1b4", Sparkle usually updates it
|
||||
// in place, giving you an app named 1.1b4 that is actually 1.2. Turn the
|
||||
|
||||
+42
-9
@@ -65,15 +65,48 @@
|
||||
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] autorelease];
|
||||
NSError *error = nil;
|
||||
NSArray *contents = [manager contentsOfDirectoryAtPath:mountPoint error:&error];
|
||||
if (error)
|
||||
{
|
||||
SULog(@"Couldn't enumerate contents of archive mounted at %@: %@", mountPoint, error);
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
NSEnumerator *contentsEnumerator = [contents objectEnumerator];
|
||||
NSString *item;
|
||||
while ((item = [contentsEnumerator nextObject]))
|
||||
{
|
||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
|
||||
// We skip any files in the DMG which are not readable.
|
||||
if (![manager isReadableFileAtPath:fromPath])
|
||||
continue;
|
||||
|
||||
SULog(@"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
||||
|
||||
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
|
||||
{
|
||||
SULog(@"Couldn't copy item: %@", error);
|
||||
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;
|
||||
|
||||
+48
-16
@@ -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] autorelease];
|
||||
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] autorelease];
|
||||
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
|
||||
|
||||
+19
-13
@@ -31,8 +31,8 @@
|
||||
- (void)updateDriverDidFinish:(NSNotification *)note;
|
||||
- (NSURL *)parameterizedFeedURL;
|
||||
|
||||
-(void) notifyWillShowAlert;
|
||||
-(void) notifyDidShowAlert;
|
||||
-(void) notifyWillShowModalAlert;
|
||||
-(void) notifyDidShowModalAlert;
|
||||
|
||||
@end
|
||||
|
||||
@@ -259,10 +259,8 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
isNetworkReachable = NO;
|
||||
}
|
||||
|
||||
if( isNetworkReachable )
|
||||
{
|
||||
[self performSelectorOnMainThread: @selector(checkForUpdatesWithDriver:) withObject: inDriver waitUntilDone: NO];
|
||||
}
|
||||
// If the network's not reachable, we pass a nil driver into checkForUpdatesWithDriver, which will then reschedule the next update so we try again later.
|
||||
[self performSelectorOnMainThread: @selector(checkForUpdatesWithDriver:) withObject: isNetworkReachable ? inDriver : nil waitUntilDone: NO];
|
||||
|
||||
[pool release];
|
||||
NS_HANDLER
|
||||
@@ -274,12 +272,6 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
|
||||
- (void)checkForUpdatesInBackground
|
||||
{
|
||||
if( [delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![delegate updaterMayCheckForUpdates: self] )
|
||||
{
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
// Background update checks should only happen if we have a network connection.
|
||||
// Wouldn't want to annoy users on dial-up by establishing a connection every
|
||||
// hour or so:
|
||||
@@ -316,7 +308,21 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
|
||||
[host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
|
||||
[self didChangeValueForKey:@"lastUpdateCheckDate"];
|
||||
|
||||
driver = [d retain];
|
||||
if( [delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![delegate updaterMayCheckForUpdates: self] )
|
||||
{
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
driver = [d retain];
|
||||
|
||||
// If we're not given a driver at all, just schedule the next update check and bail.
|
||||
if (!driver)
|
||||
{
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
NSURL* theFeedURL = [self parameterizedFeedURL];
|
||||
if( theFeedURL ) // Use a NIL URL to cancel quietly.
|
||||
[driver checkForUpdatesAtURL: theFeedURL host:host];
|
||||
|
||||
Reference in new issue
Block a user