hypriot / flash

Command line script to flash SD card images of any kind
MIT License
1k stars 176 forks source link

Cache OS downloads? #123

Closed GeoffreyPlitt closed 6 years ago

GeoffreyPlitt commented 6 years ago

Love the http syntax, but does it download fresh every time? Could it use LastModified or ETAGs or some other http technique to avoid downloading the second time, and use local copy?

StefanScherer commented 6 years ago

Great ideas. What flash does: It first tries to find the image file in /tmp where it gets extracted. See https://github.com/hypriot/flash/blob/58c68b0067f197c9641947bb2f7bedf9cd202a24/flash#L495-L500 It's a "better than nothing" kind of cache without all these fancy stuff. If we want to support cache better then new questions arise, who big should this cache be, ...

GeoffreyPlitt commented 6 years ago

Shoot, I should have noticed that-- it sounds great, nothing more needed!

GeoffreyPlitt commented 6 years ago

Actually, the /tmp cache doesn't seem to be working.

I just flashed a Pi successfully with sudo flash --force https://downloads.raspberrypi.org/raspbian_lite_latest

Inserted a new card, did it again, it downloaded the OS again instead of using /tmp.

Thoughts?

StefanScherer commented 6 years ago

The simple cache doesn't work with download links that use a different name than the extracted img file. Look inside /tmp. You can use that /tmp/xxxx name for further flashes or send me a PR to fix it :-)

GeoffreyPlitt commented 6 years ago

Oh duh. I can use a more specific URL, the one above is likely a redirect. Thanks again.