Asset Fetcher: avoid clashes by using namespace dirs
The current implementation fails to cache multiple files if their name is the same. The filename *only* will be considered when looking at the cached directories, and if hashes are not given, users will end up with the wrong files, even when they give unique URLs to different files. To give a real example, suppose we have one test that needs a specific asset file (such as an specific kernel version): def test_x86_64(self): self.fetch_asset('https://avocado-project.org/data/linux/x86_64/vmlinuz', asset_hash='0123456789abcdef...') While a second test wants the daily version of a given asset: def test_aarch64(self): self.fetch_asset('https://avocado-project.org/data/linux/aarch64/vmlinuz', expire='1d') If test_x86_64() runs first, it will write to $CACHE_DIR/vmlinuz. The second test, test_aarch64(), may end up having the completely wrong file. Using `asset_cache` is not a possibility, given that it wants the daily kernel. These changes put asset files on a "cache relative directory". If a hash is given, it's safe to put files in a directory indexed "by name". If not, they're put in a directory named after the URL (minus the filename). Signed-off-by: NCleber Rosa <crosa@redhat.com>
Showing
想要评论请 注册 或 登录