Refactoring feed download + favicon cache

This commit is contained in:
relikd
2019-09-15 23:27:01 +02:00
parent ad607bc22b
commit 4075073d1b
36 changed files with 1360 additions and 797 deletions

View File

@@ -51,6 +51,7 @@
[self scheduleNow:retryWaitTime];
}
/// Copy Etag & Last-Modified headers and update URL (if not 304). Then schedule new update date. Will reset errorCount to @c 0
- (void)setSucessfulWithResponse:(NSHTTPURLResponse*)response {
self.errorCount = 0; // reset counter
NSDictionary *header = [response allHeaderFields];
@@ -68,26 +69,17 @@
if (![self.url isEqualToString:url]) self.url = url;
}
/// Set @c refresh attribute but only if value differs.
- (void)setRefreshIfChanged:(int32_t)refresh {
if (self.refresh != refresh) self.refresh = refresh;
}
/// Set @c etag and @c modified attributes. Only values that differ will be updated.
- (void)setEtag:(NSString*)etag modified:(NSString*)modified {
if (![self.etag isEqualToString:etag]) self.etag = etag;
if (![self.modified isEqualToString:modified]) self.modified = modified;
}
/**
Set @c refresh and calculate new @c scheduled date.
@return @c YES if refresh interval has changed
*/
- (BOOL)setRefreshAndSchedule:(int32_t)refresh {
if (self.refresh != refresh) {
self.refresh = refresh;
[self scheduleNow:self.refresh];
return YES;
}
return NO;
}
/// Set next scheduled feed update or @c nil if @c refresh @c <= @c 0.
- (void)scheduleNow:(NSTimeInterval)future {
if (self.refresh <= 0) { // update deactivated; manually update with force update all