From 9e82dc914a1ac50a1ee789664921679e2fefef45 Mon Sep 17 00:00:00 2001 From: memsharded Date: Sun, 15 Oct 2023 22:40:28 +0200 Subject: [PATCH 1/2] make cache DB always use forward slash for paths --- conan/internal/cache/cache.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conan/internal/cache/cache.py b/conan/internal/cache/cache.py index b6d44b1e782..9ba7ee35820 100644 --- a/conan/internal/cache/cache.py +++ b/conan/internal/cache/cache.py @@ -51,7 +51,7 @@ def _short_hash_path(h): def _get_tmp_path(ref: RecipeReference): # The reference will not have revision, but it will be always constant h = ref.name[:5] + DataCache._short_hash_path(ref.repr_notime()) - return os.path.join("t", h) + return f"t/{h}" @staticmethod def _get_tmp_path_pref(pref): @@ -60,7 +60,7 @@ def _get_tmp_path_pref(pref): assert pref.timestamp is None random_id = str(uuid.uuid4()) h = pref.ref.name[:5] + DataCache._short_hash_path(pref.repr_notime() + random_id) - return os.path.join("b", h) + return f"b/{h}" @staticmethod def _get_path(ref: RecipeReference): @@ -181,6 +181,7 @@ def assign_prev(self, layout: PackageLayout): pref.timestamp = revision_timestamp_now() # Wait until it finish to really update the DB relpath = os.path.relpath(layout.base_folder, self._base_folder) + relpath = relpath.replace("\\", "/") # Uniform for Windows and Linux try: self._db.create_package(relpath, pref, build_id) except ConanReferenceAlreadyExistsInDB: From 720c055d4124e742c72c64b5307f411dd4bfa688 Mon Sep 17 00:00:00 2001 From: memsharded Date: Sun, 15 Oct 2023 23:20:25 +0200 Subject: [PATCH 2/2] review --- conan/internal/cache/cache.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/conan/internal/cache/cache.py b/conan/internal/cache/cache.py index 9ba7ee35820..0cb5e81734b 100644 --- a/conan/internal/cache/cache.py +++ b/conan/internal/cache/cache.py @@ -51,7 +51,7 @@ def _short_hash_path(h): def _get_tmp_path(ref: RecipeReference): # The reference will not have revision, but it will be always constant h = ref.name[:5] + DataCache._short_hash_path(ref.repr_notime()) - return f"t/{h}" + return os.path.join("t", h) @staticmethod def _get_tmp_path_pref(pref): @@ -60,7 +60,7 @@ def _get_tmp_path_pref(pref): assert pref.timestamp is None random_id = str(uuid.uuid4()) h = pref.ref.name[:5] + DataCache._short_hash_path(pref.repr_notime() + random_id) - return f"b/{h}" + return os.path.join("b", h) @staticmethod def _get_path(ref: RecipeReference): @@ -111,7 +111,8 @@ def get_package_layout(self, pref: PkgReference): assert pref.revision, "Package revision must be known to get the package layout" pref_data = self._db.try_get_package(pref) pref_path = pref_data.get("path") - return PackageLayout(pref, os.path.join(self._base_folder, pref_path)) + # we use abspath to convert cache forward slash in Windows to backslash + return PackageLayout(pref, os.path.abspath(os.path.join(self._base_folder, pref_path))) def get_or_create_ref_layout(self, ref: RecipeReference): """ called by RemoteManager.get_recipe()