Skip to content

Populate download cache on upload#20163

Draft
AbrilRBS wants to merge 2 commits into
conan-io:develop2from
AbrilRBS:ar/populate-cache-on-upload
Draft

Populate download cache on upload#20163
AbrilRBS wants to merge 2 commits into
conan-io:develop2from
AbrilRBS:ar/populate-cache-on-upload

Conversation

@AbrilRBS

Copy link
Copy Markdown
Member

Changelog: Feature: Populate download cache with uploaded artifacts if core.download:download_cache is set
Docs: TODO

Closes #13840, continues #15223

@memsharded memsharded left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Necessary? Covered by tests? Maybe can be dropped.

Comment on lines +15 to +23
_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))
""")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user/channel can be probably dropped for these tests for simplicity

Comment on lines +238 to +240
""" 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
"""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this. A misconfigured relative cache should have probably failed earlier? Maybe this can be reconsidered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] Populate download_cache on upload

2 participants