Make content length RSS attribute optional but highly recommended

This commit is contained in:
Zorg committed 2016-07-29 21:17:16 -04:00
1 parent 5852ecf0e7
commit 32584ab228
2 files changed
+6 -17

No files matched your search

+2 -13
View File
@@ -66,9 +66,6 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
_infoURL = [decoder decodeObjectOfClass:[NSURL class] forKey:SUAppcastItemInfoURLKey];
_contentLength = (NSUInteger)[decoder decodeIntegerForKey:SUAppcastItemContentLengthKey];
if (_contentLength == 0) {
return nil;
}
_installationType = [decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemInstallationTypeKey];
if (!SUValidInstallationType(_installationType)) {
@@ -238,18 +235,10 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
NSInteger contentLength = 0;
if (enclosureLengthString != nil) {
contentLength = [enclosureLengthString integerValue];
}
if (contentLength > 0) {
_contentLength = (NSUInteger)contentLength;
} else {
// content length is important enough to require
// developers copying the sample appcast should be using it already,
// and we can get away with assuming the content length provided is valid
if (error != NULL) {
*error = @"Feed item's enclosure lacks length";
}
return nil;
SULog(@"warning: <%@> for URL '%@' is missing %@ attribute. Downloading progress may be unreliable. Please always specify %@", SURSSElementEnclosure, [enclosure objectForKey:SURSSAttributeURL], SURSSAttributeLength, SURSSAttributeLength);
}
_contentLength = (contentLength > 0) ? (NSUInteger)contentLength : 0;
}
if (enclosureURLString) {
+4 -4
View File
@@ -146,7 +146,7 @@
dispatch_async(dispatch_get_main_queue(), ^{
self.retrievedDownloadResult = YES;
if (self.expectedContentLength > 0 && self.expectedContentLength != self.updateItem.contentLength) {
if (self.expectedContentLength > 0 && self.updateItem.contentLength > 0 && self.expectedContentLength != self.updateItem.contentLength) {
SULog(@"Warning: Downloader's expected content length (%lu) != Appcast item's length (%lu)", self.expectedContentLength, self.updateItem.contentLength);
}
@@ -193,10 +193,10 @@
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)expectedContentLength
{
dispatch_async(dispatch_get_main_queue(), ^{
// We only notify the expected content length once and we use the content length from the appcast instead of from the downloader,
// so that we an expected length for the entire download rather than a single piece of block
// We only notify the expected content length once and we try to use the content length from the appcast instead of from the downloader,
// so that we have an expected length for the entire download rather than a single piece of block
if (!self.retrievedDownloadResponse) {
[self.delegate downloadDriverDidReceiveExpectedContentLength:self.updateItem.contentLength];
[self.delegate downloadDriverDidReceiveExpectedContentLength:(self.updateItem.contentLength > 0 ? self.updateItem.contentLength : (NSUInteger)expectedContentLength)];
self.retrievedDownloadResponse = YES;
}