[Enhancement] Do not download if already cached #428
Comments
If the file exists and it is the size we expect it to be, don't download the file again.
How about verifying the checksum of the cached file as well (if the checksum is provided)? It would make it possible to automatically recover from corrupted downloads, when length matches but content does not. Currently such file will not be downloaded, but will fail the checksum test later. |
That make sense. I think we may be doing that already though. |
@jberezanski Yup, check out #427. |
Note that we verify the file downloaded with the checksum whether or not we using the cache - https://github.com/chocolatey/chocolatey/blob/master/src/helpers/functions/Get-ChocolateyWebFile.ps1#L126 |
Yes, I've seen that line (that's what I meant by "the checksum test later"). However, in the scenario I'm thinking about, it would be too late. Please consider the following sequence of events:
I propose modifying L85 to: if ($fi.Exists -and ($fi.Length -eq $headers["Content-Length"]) -and (Get-CheckSumValid -file $fi -checkSum $checksum -checksumType $checksumType)) That change would result in failing the condition at step 9 above and redownloading the file, hopefully uncorrupted this time. Without that change, the user would need to delete the cached file by hand (be familiar with cache directory location and layout etc) to fix the broken download. |
Ah yeah, perfect use case. Let's get that in there. File an enhancement? On Monday, March 3, 2014, Jakub Berezanski notifications@github.com wrote:
Rob http://devlicio.us/blogs/rob_reynolds |
@ferventcoder I am just spitballing here, but does the implementation of this feature give us the "complete offline install"? Assuming you have already run all the installations once on one machine, and you can transport the cache folder to another machine, you would then be in a position to run all the installs again on that other machine without the need to go off to the internet, right? Or was this part of your cunning plan all along? :-) |
Check the cache and if the file that you are to download already exists and has the same length as the Content-Length of the expected file, do not re-download the file.
This is super similar to GH-109 but will be implemented in a slightly different way.
The text was updated successfully, but these errors were encountered: