vagrant: Avoid download of partial cached files
vagrant: Avoid download of partial cached files

During VM provisioning, we cache some downloaded files outside the VM,
to speed up subsequent provisionings. If a cached file is present we
consider that it's safe to reuse. That is however not the case when the
download was interrupted (e.g., because of a network error or because VM
provisioning was interrupted). Ideally we would check the signature of
downloaded files, but the associated projects have different ways of
exposing the signatures.

This commit changes download_to() to download files in /tmp and move
them to the cache only once the download is succesfull. This behavior
requires the use of 'set -e'. The cache may still end with partial files
if provisioning is interrupted while the file is moved out of /tmp. That
operation is however much faster than the download and an interruption
therefore less likely.

Signed-off-by: Paul Chaignon <a027184a55211cd23e3f3094f1fdc728df5e0500@cilium.io>

cilium/cilium,michi-covalent/cilium,cilium-team/cilium,michi-covalent/cilium,tgraf/cilium,tgraf/cilium,tgraf/cilium,tgraf/cilium,tklauser/cilium,tgraf/cilium,tklauser/cilium,tklauser/cilium,tgraf/cilium,michi-covalent/cilium,tklauser/cilium,cilium/cilium,cilium/cilium,tklauser/cilium,cilium-team/cilium,cilium/cilium,michi-covalent/cilium,cilium/cilium,michi-covalent/cilium