Make caching of downloaded files more atomic