Fix files being created even when download failed #885
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This was causing failures during repeated fetches when the first fails to download files.
HttpClient
was creating a temporary file under a unique name as a placeholder, then the download would fail and not write anything to that temp file, and finally it would rename that file to the expected name. The bad file existing was triggering a cache hit and causing failures once the files could not be extracted from.Preventing the rename is not thorough enough, because the temporary files were still left in the cache.
Bug: 395979597
Test: cvd fetch --target_directory=/tmp/cvd/cache_test --default_build=11407015/cf_x86_64_phone-userdebug_coverage Test: # expected failure becaue the file is not found Test: ls /tmp/cvd/cache_test # no host tools or images Test: ls
/tmp/cvd/cache/<user_id>/11407015/cf_x86_64_phone-userdebug_coverage Test: # directories for build+target exist, but no files leftover