Merge branch '1.17.x' into touchbar

This commit is contained in:
Bi11 committed 2017-01-13 21:30:09 +08:00
commit aa29a754e6
9 files changed
+42 -10

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@ SU_EXPORT @interface SUAppcast : NSObject<NSURLDownloadDelegate>
@property (copy, nullable) NSString *userAgentString;
@property (copy, nullable) NSDictionary *httpHeaders;
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *_Nullable))err;
- (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)bg completionBlock:(void (^)(NSError *_Nullable))err;
- (SUAppcast *)copyWithoutDeltaUpdates;
@property (readonly, copy, nullable) NSArray *items;
+5 -1
View File
@@ -54,11 +54,15 @@
@synthesize download;
@synthesize items;
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))block
- (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)background completionBlock:(void (^)(NSError *))block
{
self.completionBlock = block;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
if (background) {
request.networkServiceType = NSURLNetworkServiceTypeBackground;
}
if (self.userAgentString) {
[request setValue:self.userAgentString forHTTPHeaderField:@"User-Agent"];
}
+4
View File
@@ -121,6 +121,10 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
return NO;
}
-(BOOL)downloadsUpdatesInBackground {
return YES;
}
- (void)stopUpdatingOnTermination
{
if (self.willUpdateOnTermination)
+7 -3
View File
@@ -65,7 +65,7 @@
id<SUUpdaterPrivate> updater = self.updater;
[appcast setUserAgentString:[updater userAgentString]];
[appcast setHttpHeaders:[updater httpHeaders]];
[appcast fetchAppcastFromURL:URL completionBlock:^(NSError *error) {
[appcast fetchAppcastFromURL:URL inBackground:self.downloadsAppcastInBackground completionBlock:^(NSError *error) {
if (error) {
[self abortUpdateWithError:error];
} else {
@@ -258,10 +258,14 @@
if ([[NSFileManager defaultManager] fileExistsAtPath:appCachePath]) {
[[NSFileManager defaultManager] removeItemAtPath:appCachePath error:NULL];
}
id<SUUpdaterPrivate> updater = self.updater;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
if (self.downloadsUpdatesInBackground) {
request.networkServiceType = NSURLNetworkServiceTypeBackground;
}
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
if ([[updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
[[updater delegate] updater:self.updater
+2
View File
@@ -32,6 +32,8 @@ extern NSString *const SUUpdateDriverFinishedNotification;
@property (getter=isInterruptible, readonly) BOOL interruptible;
@property (readonly) BOOL finished;
@property (readonly) BOOL downloadsAppcastInBackground;
@property (readonly) BOOL downloadsUpdatesInBackground;
@property BOOL automaticallyInstallUpdates;
@end
+8
View File
@@ -56,6 +56,14 @@ NSString *const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
return NO;
}
-(BOOL)downloadsAppcastInBackground {
return YES;
}
-(BOOL)downloadsUpdatesInBackground {
return NO;
}
- (void)showAlert:(NSAlert *)alert {
// Only UI-based subclass shows the actual alert
SULog(SULogLevelDefault, @"ALERT: %@\n%@", alert.messageText, alert.informativeText);
+4
View File
@@ -80,6 +80,10 @@
[super abortUpdate];
}
-(BOOL)downloadsAppcastInBackground {
return NO;
}
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
{
// We don't check to see if this update's been skipped, because the user explicitly *asked* if he had the latest version.
+7 -4
View File
@@ -98,11 +98,14 @@ class ArchiveItem: CustomStringConvertible {
return "\(self.archivePath) \(self.version)"
}
var archiveURL: URL {
if let relative = self.feedURL {
return URL(string: self.archivePath.lastPathComponent, relativeTo: relative)!
var archiveURL: URL? {
guard let escapedFilename = self.archivePath.lastPathComponent.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else {
return nil;
}
return URL(string: self.archivePath.lastPathComponent)!
if let relative = self.feedURL {
return URL(string: escapedFilename, relativeTo: relative)
}
return URL(string: escapedFilename)
}
var pubDate : String {
+4 -1
View File
@@ -117,8 +117,11 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
item.addChild(enclosure!);
}
guard let archiveURL = update.archiveURL?.absoluteString else {
throw makeError(code: .appcastError, "Bad archive name or feed URL");
};
var attributes = [
XMLNode.attribute(withName: "url", stringValue: update.archiveURL.absoluteString) as! XMLNode,
XMLNode.attribute(withName: "url", stringValue: archiveURL) as! XMLNode,
XMLNode.attribute(withName: "sparkle:version", uri: sparkleNS, stringValue: update.version) as! XMLNode,
XMLNode.attribute(withName: "length", stringValue: String(update.fileSize)) as! XMLNode,
XMLNode.attribute(withName: "type", stringValue: update.mimeType) as! XMLNode,