Add an unarchiver for the delta format so that Sparkle can successfully install the delta updates.

This commit is contained in:
Mark Rowe committed 2009-08-21 14:40:00 -07:00
1 parent 6e648f14f4
commit 79bd7ac090
7 files changed
+87 -6

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
//
// SUBinaryDeltaUnarchiver.h
// Sparkle
//
// Created by Mark Rowe on 2009-06-03.
// Copyright 2009 Mark Rowe. All rights reserved.
//
#ifndef SUBINARYDELTAUNARCHIVER_H
#define SUBINARYDELTAUNARCHIVER_H
#import <Cocoa/Cocoa.h>
#import "SUUnarchiver.h"
@interface SUBinaryDeltaUnarchiver : SUUnarchiver {
}
@end
#endif
+47
View File
@@ -0,0 +1,47 @@
//
// SUBinaryDeltaUnarchiver.m
// Sparkle
//
// Created by Mark Rowe on 2009-06-03.
// Copyright 2009 Mark Rowe. All rights reserved.
//
#import "SUBinaryDeltaUnarchiver.h"
#import "SUBinaryDeltaApply.h"
#import "SUUnarchiver_Private.h"
#import "SUHost.h"
#import "NTSynchronousTask.h"
@implementation SUBinaryDeltaUnarchiver
+ (BOOL)_canUnarchivePath:(NSString *)path
{
return [[path pathExtension] isEqualToString:@"delta"];
}
- (void)start
{
[NSThread detachNewThreadSelector:@selector(_applyBinaryDelta) toTarget:self withObject:nil];
}
- (void)_applyBinaryDelta
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *sourcePath = [[updateHost bundle] bundlePath];
NSString *targetPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
int result = applyBinaryDelta(sourcePath, targetPath, archivePath);
if (!result)
[self performSelectorOnMainThread:@selector(_notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO];
else
[self performSelectorOnMainThread:@selector(_notifyDelegateOfFailure) withObject:nil waitUntilDone:NO];
[pool drain];
}
+ (void)load
{
[self _registerImplementation:self];
}
@end
+4 -1
View File
@@ -9,12 +9,15 @@
#ifndef SUUNARCHIVER_H
#define SUUNARCHIVER_H
@class SUHost;
@interface SUUnarchiver : NSObject {
id delegate;
NSString *archivePath;
SUHost *updateHost;
}
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path;
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host;
- (void)setDelegate:delegate;
- (void)start;
+2 -2
View File
@@ -15,14 +15,14 @@
extern NSMutableArray *__unarchiverImplementations;
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host
{
NSEnumerator *implementationEnumerator = [[self _unarchiverImplementations] objectEnumerator];
id current;
while ((current = [implementationEnumerator nextObject]))
{
if ([current _canUnarchivePath:path])
return [[[current alloc] _initWithPath:path] autorelease];
return [[[current alloc] _initWithPath:path host:host] autorelease];
}
return nil;
}
+1 -1
View File
@@ -16,7 +16,7 @@
+ (void)_registerImplementation:(Class)implementation;
+ (NSArray *)_unarchiverImplementations;
+ (BOOL)_canUnarchivePath:(NSString *)path;
- _initWithPath:(NSString *)path;
- _initWithPath:(NSString *)path host:(SUHost *)host;
- (void)_notifyDelegateOfExtractedLength:(long)length;
- (void)_notifyDelegateOfSuccess;
+5 -2
View File
@@ -10,16 +10,19 @@
@implementation SUUnarchiver (Private)
- _initWithPath:(NSString *)path
- _initWithPath:(NSString *)path host:(SUHost *)host
{
if ((self = [super init]))
if ((self = [super init])) {
archivePath = [path copy];
updateHost = [host retain];
}
return self;
}
- (void)dealloc
{
[archivePath release];
[updateHost release];
[super dealloc];
}
+8
View File
@@ -18,6 +18,8 @@
5D06E8FF0FD68D6D005AE3F6 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; };
5D06E9000FD68D6D005AE3F6 /* libxar.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8F90FD68D53005AE3F6 /* libxar.dylib */; };
5D06E9050FD68D7D005AE3F6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
5D06E9390FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D06E9370FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h */; };
5D06E93A0FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E9380FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m */; };
610134730DD250470049ACDF /* SUUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 610134710DD250470049ACDF /* SUUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
610134740DD250470049ACDF /* SUUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 610134720DD250470049ACDF /* SUUpdateDriver.m */; };
6101347B0DD2541A0049ACDF /* SUProbingUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 610134790DD2541A0049ACDF /* SUProbingUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
@@ -176,6 +178,8 @@
5D06E8F30FD68D21005AE3F6 /* ConfigBinaryDeltaRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigBinaryDeltaRelease.xcconfig; sourceTree = "<group>"; };
5D06E8F90FD68D53005AE3F6 /* libxar.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxar.dylib; path = /usr/lib/libxar.dylib; sourceTree = "<absolute>"; };
5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbz2.dylib; path = /usr/lib/libbz2.dylib; sourceTree = "<absolute>"; };
5D06E9370FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBinaryDeltaUnarchiver.h; sourceTree = "<group>"; };
5D06E9380FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaUnarchiver.m; sourceTree = "<group>"; };
610134710DD250470049ACDF /* SUUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdateDriver.h; sourceTree = "<group>"; };
610134720DD250470049ACDF /* SUUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdateDriver.m; sourceTree = "<group>"; };
610134790DD2541A0049ACDF /* SUProbingUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUProbingUpdateDriver.h; sourceTree = "<group>"; };
@@ -447,6 +451,8 @@
5D06E8E10FD68CC7005AE3F6 /* SUBinaryDeltaCommon.h */,
5D06E8E20FD68CC7005AE3F6 /* SUBinaryDeltaCommon.m */,
5D06E8E30FD68CC7005AE3F6 /* SUBinaryDeltaTool.m */,
5D06E9370FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h */,
5D06E9380FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m */,
);
name = "Binary Delta";
sourceTree = "<group>";
@@ -667,6 +673,7 @@
6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */,
61EF67590E25C5B400F754E0 /* SUHost.h in Headers */,
61CFB3290E385186007A1735 /* Sparkle.pch in Headers */,
5D06E9390FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -983,6 +990,7 @@
5D06E8EB0FD68CE4005AE3F6 /* bspatch.c in Sources */,
5D06E8EC0FD68CE4005AE3F6 /* SUBinaryDeltaApply.m in Sources */,
5D06E8ED0FD68CE4005AE3F6 /* SUBinaryDeltaCommon.m in Sources */,
5D06E93A0FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};