mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Merge branch '1.17.x' into touchbar
This commit is contained in:
commit
aa29a754e6
9 files changed
+42
-10
No files matched your search
Vendored
+1
-1
@@ -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;
|
||||
|
||||
Vendored
+5
-1
@@ -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"];
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -121,6 +121,10 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
return NO;
|
||||
}
|
||||
|
||||
-(BOOL)downloadsUpdatesInBackground {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)stopUpdatingOnTermination
|
||||
{
|
||||
if (self.willUpdateOnTermination)
|
||||
|
||||
Vendored
+7
-3
@@ -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
|
||||
|
||||
Vendored
+2
@@ -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
|
||||
|
||||
Vendored
+8
@@ -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
@@ -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.
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user