Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 313 lines (263 sloc) 14.03 kB
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
1 //
2 // SUBasicUpdateDriver.m
3 // Sparkle
4 //
5 // Created by Andy Matuschak on 4/23/08.
6 // Copyright 2008 Andy Matuschak. All rights reserved.
7 //
8
9 #import "SUBasicUpdateDriver.h"
10
f815eec @andymatuschak Fixes 243884
andymatuschak authored
11 #import "SUHost.h"
de9be8b @andymatuschak Fixes 244428
andymatuschak authored
12 #import "SUDSAVerifier.h"
f815eec @andymatuschak Fixes 243884
andymatuschak authored
13 #import "SUInstaller.h"
14 #import "SUStandardVersionComparator.h"
15 #import "SUUnarchiver.h"
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
16
17 @implementation SUBasicUpdateDriver
18
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
19 - (void)checkForUpdatesAtURL:(NSURL *)appcastURL host:(SUHost *)aHost
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
20 {
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
21 [super checkForUpdatesAtURL:appcastURL host:aHost];
3146ffb @andymatuschak Fixes 248929, 244738
andymatuschak authored
22 if ([aHost isRunningOnReadOnlyVolume])
8b3d15b @andymatuschak Moved the check for whether the host is running from a disk image to …
andymatuschak authored
23 {
3146ffb @andymatuschak Fixes 248929, 244738
andymatuschak authored
24 [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [aHost name]] forKey:NSLocalizedDescriptionKey]]];
8b3d15b @andymatuschak Moved the check for whether the host is running from a disk image to …
andymatuschak authored
25 return;
26 }
27
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
28 SUAppcast *appcast = [[SUAppcast alloc] init];
29 CFRetain(appcast); // We'll manage the appcast's memory ourselves so we don't have to make it an IV to support GC.
30 [appcast release];
31
32 [appcast setDelegate:self];
7ce078e @andymatuschak Fixes 356328
andymatuschak authored
33 NSString *userAgent = [NSString stringWithFormat: @"%@/%@ Sparkle/%@", [aHost name], [aHost displayVersion], ([SPARKLE_BUNDLE objectForInfoDictionaryKey:@"CFBundleVersion"] ?: nil)];
34 NSData * cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
35 userAgent = [NSString stringWithCString:[cleanedAgent bytes] length:[cleanedAgent length]];
36 [appcast setUserAgentString:userAgent];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
37 [appcast fetchAppcastFromURL:appcastURL];
38 }
39
aaa60d2 @andymatuschak Fixed 244761
andymatuschak authored
40 - (id <SUVersionComparison>)_versionComparator
41 {
42 id <SUVersionComparison> comparator = nil;
43
44 // Give the delegate a chance to provide a custom version comparator
b3f3944 @andymatuschak Fixes 244857
andymatuschak authored
45 if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)])
46 comparator = [[updater delegate] versionComparatorForUpdater:updater];
aaa60d2 @andymatuschak Fixed 244761
andymatuschak authored
47
48 // If we don't get a comparator from the delegate, use the default comparator
49 if (!comparator)
50 comparator = [SUStandardVersionComparator defaultComparator];
51
52 return comparator;
53 }
54
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
55 - (BOOL)isItemNewer:(SUAppcastItem *)ui
56 {
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
57 return [[self _versionComparator] compareVersion:[host version] toVersion:[ui versionString]] == NSOrderedAscending;
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
58 }
59
60 - (BOOL)hostSupportsItem:(SUAppcastItem *)ui
61 {
62 if ([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) { return YES; }
de9be8b @andymatuschak Fixes 244428
andymatuschak authored
63 return [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedDescending;
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
64 }
65
66 - (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
67 {
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
68 NSString *skippedVersion = [host objectForUserDefaultsKey:SUSkippedVersionKey];
1264a6b @andymatuschak Sparkle now finds the newest update in an appcast for which the host …
andymatuschak authored
69 if (skippedVersion == nil) { return NO; }
aaa60d2 @andymatuschak Fixed 244761
andymatuschak authored
70 return [[self _versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
71 }
72
73 - (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
74 {
75 return [self hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
76 }
77
78 - (void)appcastDidFinishLoading:(SUAppcast *)ac
79 {
b3f3944 @andymatuschak Fixes 244857
andymatuschak authored
80 if ([[updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)])
81 [[updater delegate] updater:updater didFinishLoadingAppcast:ac];
d201803 @andymatuschak More fixes for 258060
andymatuschak authored
82
83 SUAppcastItem *item = nil;
84
5c32832 @andymatuschak Fixes bug 228446
andymatuschak authored
85 // Now we have to find the best valid update in the appcast.
b3f3944 @andymatuschak Fixes 244857
andymatuschak authored
86 if ([[updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
5c32832 @andymatuschak Fixes bug 228446
andymatuschak authored
87 {
d201803 @andymatuschak More fixes for 258060
andymatuschak authored
88 item = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:updater];
5c32832 @andymatuschak Fixes bug 228446
andymatuschak authored
89 }
90 else // If not, we'll take care of it ourselves.
91 {
92 // Find the first update we can actually use.
251706d @andymatuschak Fixed a serious bug which could cause a server to DDoS'd in the case …
andymatuschak authored
93 NSEnumerator *updateEnumerator = [[ac items] objectEnumerator];
5c32832 @andymatuschak Fixes bug 228446
andymatuschak authored
94 do {
d201803 @andymatuschak More fixes for 258060
andymatuschak authored
95 item = [updateEnumerator nextObject];
96 } while (item && ![self hostSupportsItem:item]);
5c32832 @andymatuschak Fixes bug 228446
andymatuschak authored
97 }
d201803 @andymatuschak More fixes for 258060
andymatuschak authored
98
99 updateItem = [item retain];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
100 CFRelease(ac); // Remember that we're explicitly managing the memory of the appcast.
101 if (updateItem == nil) { [self didNotFindUpdate]; return; }
102
103 if ([self itemContainsValidUpdate:updateItem])
104 [self didFindValidUpdate];
105 else
106 [self didNotFindUpdate];
107 }
108
109 - (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error
110 {
111 CFRelease(ac); // Remember that we're explicitly managing the memory of the appcast.
112 [self abortUpdateWithError:error];
113 }
114
115 - (void)didFindValidUpdate
116 {
b3f3944 @andymatuschak Fixes 244857
andymatuschak authored
117 if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
118 [[updater delegate] updater:updater didFindValidUpdate:updateItem];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
119 [self downloadUpdate];
120 }
121
122 - (void)didNotFindUpdate
123 {
b3f3944 @andymatuschak Fixes 244857
andymatuschak authored
124 if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)])
125 [[updater delegate] updaterDidNotFindUpdate:updater];
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
126 [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUNoUpdateError userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", nil), [host name]] forKey:NSLocalizedDescriptionKey]]];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
127 }
128
129 - (void)downloadUpdate
130 {
131 download = [[NSURLDownload alloc] initWithRequest:[NSURLRequest requestWithURL:[updateItem fileURL]] delegate:self];
132 }
133
134 - (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSString *)name
135 {
136 // If name ends in .txt, the server probably has a stupid MIME configuration. We'll give the developer the benefit of the doubt and chop that off.
137 if ([[name pathExtension] isEqualToString:@"txt"])
138 name = [name stringByDeletingPathExtension];
139
140 // We create a temporary directory in /tmp and stick the file there.
141 // Not using a GUID here because hdiutil for some reason chokes on GUIDs. Too long? I really have no idea.
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
142 NSString *prefix = [NSString stringWithFormat:@"%@ %@ Update", [host name], [host version]];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
143 NSString *tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:prefix];
144 int cnt=1;
145 while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999999)
146 tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", prefix, cnt++]];
147 BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir attributes:nil];
148 if (!success)
149 {
150 // Okay, something's really broken with /tmp
151 [download cancel];
152 [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.",tempDir] forKey:NSLocalizedDescriptionKey]]];
153 }
154
155 downloadPath = [[tempDir stringByAppendingPathComponent:name] retain];
156 [download setDestination:downloadPath allowOverwrite:YES];
157 }
158
159 - (void)downloadDidFinish:(NSURLDownload *)d
160 {
161 [self extractUpdate];
162 }
163
164 - (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error
165 {
49f717c @andymatuschak Fixes #230173 by removing partially downloaded files on download error.
andymatuschak authored
166 // Get rid of what we've downloaded so far, if anything.
167 if (downloadPath != nil)
168 [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[downloadPath stringByDeletingLastPathComponent] destination:@"" files:[NSArray arrayWithObject:[downloadPath lastPathComponent]] tag:NULL];
8dfd93e @andymatuschak Made the error displayed on download failure human-friendly.
andymatuschak authored
169 [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil), NSLocalizedDescriptionKey, [error localizedDescription], NSLocalizedFailureReasonErrorKey, nil]]];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
170 }
171
c9bd132 @andymatuschak Fixes 246469
andymatuschak authored
172 - (BOOL)download:(NSURLDownload *)download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
173 {
0af86bb @andymatuschak Hopefully actually fixing 246469: it seems that while Cocoa documents…
andymatuschak authored
174 // We don't want the download system to extract our gzips.
175 // Note that we use a substring matching here instead of direct comparison because the docs say "application/gzip" but the system *uses* "application/x-gzip". This is a documentation bug.
898216a @andymatuschak Final fix for 246469 (I hope). Fixed a mind-bogglingly stupid typo wh…
andymatuschak authored
176 return ([encodingType rangeOfString:@"gzip"].location == NSNotFound);
c9bd132 @andymatuschak Fixes 246469
andymatuschak authored
177 }
178
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
179 - (void)extractUpdate
180 {
181 // DSA verification, if activated by the developer
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
182 if ([[host objectForInfoDictionaryKey:SUExpectsDSASignatureKey] boolValue])
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
183 {
de9be8b @andymatuschak Fixes 244428
andymatuschak authored
184 if (![SUDSAVerifier validatePath:downloadPath withEncodedDSASignature:[updateItem DSASignature] withPublicDSAKey:[host publicDSAKey]])
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
185 {
186 [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:[NSDictionary dictionaryWithObject:@"The update is improperly signed." forKey:NSLocalizedDescriptionKey]]];
187 return;
188 }
189 }
190
58a05e2 @andymatuschak Fixes 243533 (for real this time, I hope)
andymatuschak authored
191 SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:downloadPath];
441a538 @andymatuschak Oops! Fixed a warning that caused Sparkle not to compile. Made the un…
andymatuschak authored
192 if (!unarchiver)
193 {
194 NSLog(@"Sparkle Error: No valid unarchiver for %@!", downloadPath);
195 [self unarchiverDidFail:nil];
764bed3 @andymatuschak Okay, *really* fixing the bug this time. Thanks for watching my back,…
andymatuschak authored
196 return;
441a538 @andymatuschak Oops! Fixed a warning that caused Sparkle not to compile. Made the un…
andymatuschak authored
197 }
3daa88d @andymatuschak --fixes lp:242525 --fixes lp:242561 --fixes lp:242564
andymatuschak authored
198 CFRetain(unarchiver); // Manage this memory manually so we don't have to make it an IV.
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
199 [unarchiver setDelegate:self];
93ea93d @andymatuschak Fixes 236695
andymatuschak authored
200 [unarchiver start];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
201 }
202
203 - (void)unarchiverDidFinish:(SUUnarchiver *)ua
204 {
441a538 @andymatuschak Oops! Fixed a warning that caused Sparkle not to compile. Made the un…
andymatuschak authored
205 if (ua) { CFRelease(ua); }
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
206 [self installUpdate];
207 }
208
209 - (void)unarchiverDidFail:(SUUnarchiver *)ua
210 {
441a538 @andymatuschak Oops! Fixed a warning that caused Sparkle not to compile. Made the un…
andymatuschak authored
211 if (ua) { CFRelease(ua); }
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
212 [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:[NSDictionary dictionaryWithObject:SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) forKey:NSLocalizedDescriptionKey]]];
213 }
214
6d8f5be @andymatuschak Merging in David Smith's branch to fix bug #230123. We now copy the r…
andymatuschak authored
215 - (BOOL)shouldInstallSynchronously { return NO; }
216
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
217 - (void)installUpdate
218 {
b3f3944 @andymatuschak Fixes 244857
andymatuschak authored
219 if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdate:)])
220 [[updater delegate] updater:updater willInstallUpdate:updateItem];
6d8f5be @andymatuschak Merging in David Smith's branch to fix bug #230123. We now copy the r…
andymatuschak authored
221 // Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
222 NSString *relaunchPathToCopy = [[NSBundle bundleForClass:[self class]] pathForResource:@"relaunch" ofType:@""];
223 NSString *targetPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
224 // Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems
225 [[NSFileManager defaultManager] removeFileAtPath:targetPath handler:nil];
226 if ([[NSFileManager defaultManager] copyPath:relaunchPathToCopy toPath:targetPath handler:nil])
227 relaunchPath = [targetPath retain];
228
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
229 [SUInstaller installFromUpdateFolder:[downloadPath stringByDeletingLastPathComponent] overHost:host delegate:self synchronously:[self shouldInstallSynchronously]];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
230 }
231
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
232 - (void)installerFinishedForHost:(SUHost *)aHost
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
233 {
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
234 if (aHost != host) { return; }
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
235 [self relaunchHostApp];
236 }
237
238 - (void)relaunchHostApp
239 {
5c32832 @andymatuschak Fixes bug 228446
andymatuschak authored
240 // Give the host app an opportunity to postpone the relaunch.
241 static BOOL postponedOnce = NO;
b3f3944 @andymatuschak Fixes 244857
andymatuschak authored
242 if (!postponedOnce && [[updater delegate] respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
5c32832 @andymatuschak Fixes bug 228446
andymatuschak authored
243 {
244 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[[self class] instanceMethodSignatureForSelector:@selector(relaunchHostApp)] retain]];
245 [invocation setSelector:@selector(relaunchHostApp)];
246 [invocation setTarget:self];
247 postponedOnce = YES;
b3f3944 @andymatuschak Fixes 244857
andymatuschak authored
248 if ([[updater delegate] updater:updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation])
5c32832 @andymatuschak Fixes bug 228446
andymatuschak authored
249 return;
250 }
46f9b4a @andymatuschak Fixes 242566
andymatuschak authored
251
252 [self cleanUp]; // Clean up the download and extracted files.
5c32832 @andymatuschak Fixes bug 228446
andymatuschak authored
253
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
254 [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
84be00b @andymatuschak Fixes 258991
andymatuschak authored
255 if ([[updater delegate] respondsToSelector:@selector(updaterWillRelaunchApplication:)])
b3f3944 @andymatuschak Fixes 244857
andymatuschak authored
256 [[updater delegate] updaterWillRelaunchApplication:updater];
5c32832 @andymatuschak Fixes bug 228446
andymatuschak authored
257
1c7fb59 @andymatuschak Killed one of the two remaining @try/@catch blocks in my code. I'll g…
andymatuschak authored
258 if(!relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath])
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
259 {
260 // Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
261 [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [host name]], NSLocalizedDescriptionKey, [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath], NSLocalizedFailureReasonErrorKey, nil]]];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
262 // We intentionally don't abandon the update here so that the host won't initiate another.
1c7fb59 @andymatuschak Killed one of the two remaining @try/@catch blocks in my code. I'll g…
andymatuschak authored
263 return;
264 }
265
e249e3c @andymatuschak Fixes 253187
andymatuschak authored
266 NSString *pathToRelaunch = [host bundlePath];
267 if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)])
268 pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater];
269 [NSTask launchedTaskWithLaunchPath:relaunchPath arguments:[NSArray arrayWithObjects:pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];
1c7fb59 @andymatuschak Killed one of the two remaining @try/@catch blocks in my code. I'll g…
andymatuschak authored
270
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
271 [NSApp terminate:self];
272 }
273
46f9b4a @andymatuschak Fixes 242566
andymatuschak authored
274 - (void)cleanUp
275 {
276 [[NSFileManager defaultManager] removeFileAtPath:[downloadPath stringByDeletingLastPathComponent] handler:nil];
277 }
278
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
279 - (void)installerForHost:(SUHost *)aHost failedWithError:(NSError *)error
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
280 {
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
281 if (aHost != host) { return; }
6d8f5be @andymatuschak Merging in David Smith's branch to fix bug #230123. We now copy the r…
andymatuschak authored
282 [[NSFileManager defaultManager] removeFileAtPath:relaunchPath handler:NULL]; // Clean up the copied relauncher.
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
283 [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while installing the update. Please try again later.", nil), NSLocalizedDescriptionKey, [error localizedDescription], NSLocalizedFailureReasonErrorKey, nil]]];
284 }
285
286 - (void)abortUpdate
287 {
288 [[NSNotificationCenter defaultCenter] removeObserver:self];
289 [super abortUpdate];
290 }
291
292 - (void)abortUpdateWithError:(NSError *)error
293 {
294 if ([error code] != SUNoUpdateError) // Let's not bother logging this.
295 NSLog(@"Sparkle Error: %@", [error localizedDescription]);
296 if ([error localizedFailureReason])
297 NSLog(@"Sparkle Error (continued): %@", [error localizedFailureReason]);
0a4bc65 @andymatuschak No longer leaking the NSURLDownload of the update archive.
andymatuschak authored
298 if (download)
299 [download cancel];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
300 [self abortUpdate];
301 }
302
303 - (void)dealloc
304 {
46312a2 @andymatuschak Fixes 258060
andymatuschak authored
305 [updateItem release];
0a4bc65 @andymatuschak No longer leaking the NSURLDownload of the update archive.
andymatuschak authored
306 [download release];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
307 [downloadPath release];
6d8f5be @andymatuschak Merging in David Smith's branch to fix bug #230123. We now copy the r…
andymatuschak authored
308 [relaunchPath release];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
309 [super dealloc];
310 }
311
312 @end
Something went wrong with that request. Please try again.