mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-28 05:14:34 +00:00
Don't tie unarchiver to host
This commit is contained in:
1 parent
5ba0b2d656
commit
d4843c90e8
6 files changed
+14
-15
No files matched your search
Vendored
+3
-4
@@ -265,14 +265,13 @@
|
||||
|
||||
- (void)extractUpdate
|
||||
{
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHost:self.host];
|
||||
if (!unarchiver)
|
||||
{
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:[[self.host bundle] bundlePath]];
|
||||
if (!unarchiver) {
|
||||
SULog(@"Error: No valid unarchiver for %@!", self.downloadPath);
|
||||
[self unarchiverDidFail:nil];
|
||||
return;
|
||||
}
|
||||
[unarchiver setDelegate:self];
|
||||
unarchiver.delegate = self;
|
||||
[unarchiver start];
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -23,7 +23,7 @@
|
||||
- (void)applyBinaryDelta
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSString *sourcePath = [[self.updateHost bundle] bundlePath];
|
||||
NSString *sourcePath = self.updateHostBundlePath;
|
||||
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
|
||||
int result = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO);
|
||||
|
||||
Vendored
+2
-2
@@ -15,10 +15,10 @@
|
||||
@interface SUUnarchiver : NSObject
|
||||
|
||||
@property (copy, readonly) NSString *archivePath;
|
||||
@property (weak, readonly) SUHost *updateHost;
|
||||
@property (weak, readonly) NSString *updateHostBundlePath;
|
||||
@property (weak) id<SUUnarchiverDelegate> delegate;
|
||||
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host;
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)host;
|
||||
|
||||
- (void)start;
|
||||
@end
|
||||
|
||||
Vendored
+5
-5
@@ -18,15 +18,15 @@
|
||||
@implementation SUUnarchiver
|
||||
|
||||
@synthesize archivePath;
|
||||
@synthesize updateHost;
|
||||
@synthesize updateHostBundlePath;
|
||||
@synthesize delegate;
|
||||
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)hostPath
|
||||
{
|
||||
for (id current in [self unarchiverImplementations])
|
||||
{
|
||||
if ([current canUnarchivePath:path]) {
|
||||
return [[current alloc] initWithPath:path host:host];
|
||||
return [[current alloc] initWithPath:path hostBundlePath:hostPath];
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
@@ -39,12 +39,12 @@
|
||||
// No-op
|
||||
}
|
||||
|
||||
- (instancetype)initWithPath:(NSString *)path host:(SUHost *)host
|
||||
- (instancetype)initWithPath:(NSString *)path hostBundlePath:(NSString *)hostPath
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
archivePath = [path copy];
|
||||
updateHost = host;
|
||||
updateHostBundlePath = hostPath;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -16,7 +16,7 @@
|
||||
+ (void)registerImplementation:(Class)implementation;
|
||||
+ (NSArray *)unarchiverImplementations;
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
- (instancetype)initWithPath:(NSString *)path host:(SUHost *)host;
|
||||
- (instancetype)initWithPath:(NSString *)archive hostBundlePath:(NSString *)host;
|
||||
|
||||
- (void)notifyDelegateOfExtractedLength:(size_t)length;
|
||||
- (void)notifyDelegateOfSuccess;
|
||||
|
||||
@@ -50,11 +50,11 @@
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSString *testFile = [tempDestDir stringByAppendingPathComponent:@"extracted file.txt"];
|
||||
[fm removeItemAtPath:testFile error:nil];
|
||||
|
||||
|
||||
XCTAssertFalse([fm fileExistsAtPath:testFile isDirectory:nil]);
|
||||
XCTAssertTrue([fm copyItemAtPath:originalArchivePath toPath:tempArchivePath error:nil]);
|
||||
|
||||
SUUnarchiver *unarc = [SUUnarchiver unarchiverForPath:tempArchivePath updatingHost:nil];
|
||||
SUUnarchiver *unarc = [SUUnarchiver unarchiverForPath:tempArchivePath updatingHostBundlePath:nil];
|
||||
|
||||
XCTAssertTrue([unarc isKindOfClass:[SUPipedUnarchiver class]]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user