Populate download cache on upload#20163
Conversation
memsharded
left a comment
There was a problem hiding this comment.
Looking good and doable without high risk
| try: | ||
| download_cache.cache_file(url, src_path) | ||
| except Exception as e: | ||
| ConanOutput().warning(f"Could not store the uploaded file in the download cache: {e}") |
There was a problem hiding this comment.
Necessary? Covered by tests? Maybe can be dropped.
| _big_file_conanfile = textwrap.dedent(""" | ||
| import os | ||
| from conan import ConanFile | ||
| class Pkg(ConanFile): | ||
| def package(self): | ||
| fileSizeInBytes = 11000000 | ||
| with open(os.path.join(self.package_folder, "data.txt"), 'wb') as fout: | ||
| fout.write(os.urandom(fileSizeInBytes)) | ||
| """) |
There was a problem hiding this comment.
If we don't want to have an expensive test with a heavy package, maybe the functionality can be indirectly tested, like if the file is in the cache, then it should be possible to remove it from the server, or remove the server, and it won't fail to install because it will find it in the cache?
| """ | ||
| client = TestClient(default_server_user=True) | ||
| client.save({"conanfile.py": self._big_file_conanfile}) | ||
| client.run("create . --name=mypkg --version=0.1 --user=user --channel=testing") |
There was a problem hiding this comment.
user/channel can be probably dropped for these tests for simplicity
| """ unlike download, upload must not fail because of a misconfigured (relative) download | ||
| cache: populating the cache is a best-effort optimization on upload, not a requirement | ||
| """ |
There was a problem hiding this comment.
I am not sure about this. A misconfigured relative cache should have probably failed earlier? Maybe this can be reconsidered.
Changelog: Feature: Populate download cache with uploaded artifacts if
core.download:download_cacheis setDocs: TODO
Closes #13840, continues #15223