Skip to content

Commit

Permalink
Fix default path fallack when core.sources:download_cache is not set (
Browse files Browse the repository at this point in the history
#15109)

* Fix default path fallack when no core.sources:download_cache is set

* Fix tests
  • Loading branch information
AbrilRBS authored Nov 15, 2023
1 parent 4614b3a commit 889ffbc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conans/client/downloaders/caching_file_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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.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
10 changes: 10 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,16 @@ 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 it's not set in global.conf
# (The rest is needed to exercise the rest of the code)
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

0 comments on commit 889ffbc

Please sign in to comment.