You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ngclient requestsfetcher result when length > max_length #1502
If RequestsFetcher downloads a URL and the content is longer than max_length, RequestFetcher does not raise but returns max_length bytes.
This is not a fatal issue but leads to a strange situation where the TargetFile.verify_length_and_hashes() actually succeeds the length check (because it got exactly max_length bytes) and only fails the hashes check.
I think RequestsFetcher should either
raise when the content is longer than max_length or
not try to return exactly max_length so that Fetcher itself can raise if length is incorrect. This would mean
RequestsFetcher: not doing the read_amount = min(self.chunk_size, max_length - bytes_received) thing
RequestsFetcher: not checking if bytes_received >= max_length in the end of the loop
Fetcher: moving the DownloadLengthMismatchError check in download_file() so it happens inside the loop
I only a had a quick look but 2 seems like the better solution: less code, more correct implementation, and only a maximum of chunk_size more downloading if the length is incorrect?
By our own definition fetch "Ensures the length of the downloaded data is up to 'max_length'." Meaning that if we implement 2 we are not complying with our own API. Or we can update the API too.
Activity
[-]ngclient requestsfetcher[/-][+]ngclient requestsfetcher result when length > max_length[/+]sechkova commentedon Jul 23, 2021
By our own definition fetch "Ensures the length of the downloaded data is up to 'max_length'." Meaning that if we implement 2 we are not complying with our own API. Or we can update the API too.