Skip to content

Commit

Permalink
trying abs path for config install (#14183)
Browse files Browse the repository at this point in the history
* trying abs path for config install

* wip

* minor refactor
  • Loading branch information
memsharded authored Aug 21, 2023
1 parent 1819908 commit 1d449da
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
5 changes: 1 addition & 4 deletions conan/internal/cache/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ def __init__(self, base_folder, db_filename):
def _create_path(self, relative_path, remove_contents=True):
path = self._full_path(relative_path)
if os.path.exists(path) and remove_contents:
self._remove_path(relative_path)
rmdir(path)
os.makedirs(path, exist_ok=True)

def _remove_path(self, relative_path):
rmdir(self._full_path(relative_path))

def _full_path(self, relative_path):
# This one is used only for rmdir and mkdir operations, not returned to user
# or stored in DB
Expand Down
2 changes: 1 addition & 1 deletion conans/client/conf/config_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _hide_password(resource):
def tmp_config_install_folder(cache):
tmp_folder = os.path.join(cache.cache_folder, "tmp_config_install")
# necessary for Mac OSX, where the temp folders in /var/ are symlinks to /private/var/
tmp_folder = os.path.realpath(tmp_folder)
tmp_folder = os.path.abspath(tmp_folder)
rmdir(tmp_folder)
mkdir(tmp_folder)
try:
Expand Down
24 changes: 24 additions & 0 deletions conans/test/functional/command/test_custom_symlink_home.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
import platform

import pytest

from conans.test.utils.scm import create_local_git_repo
from conans.test.utils.test_files import temp_folder
from conans.test.utils.tools import TestClient
from conans.util.files import save


@pytest.mark.skipif(platform.system() == "Windows", reason="Uses symlinks")
def test_custom_symlinked_home_config_install():
base_cache = temp_folder()
real_cache = os.path.join(base_cache, "real_cache")
os.makedirs(real_cache)
symlink_cache = os.path.join(base_cache, "symlink_cache")
os.symlink(real_cache, symlink_cache)
origin_folder = temp_folder()
save(os.path.join(origin_folder, "myfile.txt"), "some contents")
create_local_git_repo(folder=origin_folder)
c = TestClient(cache_folder=symlink_cache)
c.run(f'config install "{origin_folder}" --type=git')
assert "Copying file myfile.txt to" in c.out

0 comments on commit 1d449da

Please sign in to comment.