Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default path fallack when core.sources:download_cache is not set #15109

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion conans/client/downloaders/caching_file_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, conanfile):
self._cache = helpers.cache
self._output = conanfile.output
self._conanfile = conanfile
self._cache_folder = helpers.cache.cache_folder
Copy link
Member

Choose a reason for hiding this comment

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

Why not using self._cache.cache_folder below?


def download(self, urls, file_path,
retry, retry_wait, verify_ssl, auth, headers, md5, sha1, sha256):
Expand All @@ -49,7 +50,7 @@ def _caching_download(self, urls, file_path,
something is found.
"""
# We are going to use the download_urls definition for backups
download_cache_folder = download_cache_folder or HomePaths(self.conan_api.cache_folder).default_sources_backup_folder
download_cache_folder = download_cache_folder or HomePaths(self._cache_folder).default_sources_backup_folder
# regular local shared download cache, not using Conan backup sources servers
backups_urls = backups_urls or ["origin"]
if download_cache_folder and not os.path.isabs(download_cache_folder):
Expand Down
9 changes: 9 additions & 0 deletions conans/test/integration/cache/backup_sources_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ def source(self):
assert f"Sources for {self.file_server.fake_url}/internet/myfile.txt found in remote backup" in self.client.out
assert f"File {self.file_server.fake_url}/mycompanystorage/mycompanyfile.txt not found in {self.file_server.fake_url}/backups/" in self.client.out

# Ensure defaults backup folder works if nothing set in global.conf
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if I understand the comment, you say nothing in the global.conf, then define the global.conf? 😅

self.client.save(
{"global.conf": f"core.sources:download_urls=['{self.file_server.fake_url}/backups/', 'origin']\n"
f"core.sources:exclude_urls=['{self.file_server.fake_url}/mycompanystorage/', '{self.file_server.fake_url}/mycompanystorage2/']"},
path=self.client.cache.cache_folder)
self.client.run("source .")
assert f"Sources for {self.file_server.fake_url}/internet/myfile.txt found in remote backup" in self.client.out
assert f"File {self.file_server.fake_url}/mycompanystorage/mycompanyfile.txt not found in {self.file_server.fake_url}/backups/" in self.client.out

def test_download_origin_first(self):
http_server_base_folder_internet = os.path.join(self.file_server.store, "internet")

Expand Down