Skip to content

Commit

Permalink
10.7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Mar 18, 2018
1 parent 57731f4 commit ea94969
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Sparkle/SPULocalCacheDirectory.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ + (void)removeOldItemsInDirectory:(NSString *)directory
NSDictionary<NSString *, id> *fileAttributes = [fileManager attributesOfItemAtPath:[directory stringByAppendingPathComponent:filename] error:NULL];
if (fileAttributes != nil)
{
NSDate *lastModificationDate = fileAttributes[NSFileModificationDate];
NSDate *lastModificationDate = [fileAttributes objectForKey:NSFileModificationDate];
if ([currentDate timeIntervalSinceDate:lastModificationDate] >= OLD_ITEM_DELETION_INTERVAL)
{
[filePathsToRemove addObject:[directory stringByAppendingPathComponent:filename]];
Expand Down
18 changes: 11 additions & 7 deletions Sparkle/SPUURLRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ - (void)encodeWithCoder:(NSCoder *)coder

- (instancetype)initWithCoder:(NSCoder *)decoder
{
NSURL *url = [decoder decodeObjectOfClass:[NSURL class] forKey:SPUURLRequestURLKey];
NSURLRequestCachePolicy cachePolicy = (NSURLRequestCachePolicy)[decoder decodeIntegerForKey:SPUURLRequestCachePolicyKey];
NSTimeInterval timeoutInterval = [decoder decodeDoubleForKey:SPUURLRequestTimeoutIntervalKey];
NSDictionary<NSString *, NSString *> *httpHeaderFields = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class]]] forKey:SPUURLRequestHttpHeaderFieldsKey];
NSURLRequestNetworkServiceType networkServiceType = (NSURLRequestNetworkServiceType)[decoder decodeIntegerForKey:SPUURLRequestNetworkServiceTypeKey];

return [self initWithURL:url cachePolicy:cachePolicy timeoutInterval:timeoutInterval httpHeaderFields:httpHeaderFields networkServiceType:networkServiceType];
if (@available(macOS 10.8, *)) {
NSURL *url = [decoder decodeObjectOfClass:[NSURL class] forKey:SPUURLRequestURLKey];
NSURLRequestCachePolicy cachePolicy = (NSURLRequestCachePolicy)[decoder decodeIntegerForKey:SPUURLRequestCachePolicyKey];
NSTimeInterval timeoutInterval = [decoder decodeDoubleForKey:SPUURLRequestTimeoutIntervalKey];
NSDictionary<NSString *, NSString *> *httpHeaderFields = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class]]] forKey:SPUURLRequestHttpHeaderFieldsKey];
NSURLRequestNetworkServiceType networkServiceType = (NSURLRequestNetworkServiceType)[decoder decodeIntegerForKey:SPUURLRequestNetworkServiceTypeKey];

return [self initWithURL:url cachePolicy:cachePolicy timeoutInterval:timeoutInterval httpHeaderFields:httpHeaderFields networkServiceType:networkServiceType];
} else {
abort(); // Not used on 10.7
}
}

- (NSURLRequest *)request
Expand Down

0 comments on commit ea94969

Please sign in to comment.