Skip to content

Commit

Permalink
add/commit: use hardlink to transfer files to the cache when `cache.t…
Browse files Browse the repository at this point in the history
…ype` is hardlink and on relink mode (#10557)
  • Loading branch information
skshetry authored Sep 17, 2024
1 parent 2c871ba commit b8266ed
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dvc/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,9 @@ def commit(self, filter_info=None, relink=True) -> None:
granular = (
self.is_dir_checksum and filter_info and filter_info != self.fs_path
)
hardlink = relink and next(iter(self.cache.cache_types), None) == "hardlink"
if granular:
obj = self._commit_granular_dir(filter_info, hardlink=False)
obj = self._commit_granular_dir(filter_info, hardlink=hardlink)
else:
staging, _, obj = self._build(
self.cache,
Expand All @@ -771,7 +772,7 @@ def commit(self, filter_info=None, relink=True) -> None:
self.cache,
{obj.hash_info},
shallow=False,
hardlink=False,
hardlink=hardlink,
callback=cb,
)
if relink:
Expand Down Expand Up @@ -1399,12 +1400,14 @@ def add( # noqa: C901

assert staging
assert obj.hash_info

hardlink = relink and next(iter(self.cache.cache_types), None) == "hardlink"
with TqdmCallback(desc=f"Adding {self} to cache", unit="file") as cb:
otransfer(
staging,
self.cache,
{obj.hash_info},
hardlink=False,
hardlink=hardlink,
shallow=False,
callback=cb,
)
Expand Down

0 comments on commit b8266ed

Please sign in to comment.