diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index 79aae4a7..1889bbe3 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -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) { diff --git a/Sparkle/SUDownloadDriver.m b/Sparkle/SUDownloadDriver.m index 727f1fb2..d3a85bd3 100644 --- a/Sparkle/SUDownloadDriver.m +++ b/Sparkle/SUDownloadDriver.m @@ -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; }