mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Tell OS when networking happens without UI
This commit is contained in:
1 parent
eafbb2cfad
commit
392cb65716
7 files changed
+31
-5
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(@"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.
|
||||
|
||||
Reference in new issue
Block a user