From b8266ed15f4c33f0558a8570eedd935bfbab6712 Mon Sep 17 00:00:00 2001 From: skshetry <18718008+skshetry@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:09:32 +0545 Subject: [PATCH] add/commit: use hardlink to transfer files to the cache when `cache.type` is hardlink and on relink mode (#10557) --- dvc/output.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dvc/output.py b/dvc/output.py index 422e1fa57..00acb4ca7 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -752,8 +752,9 @@ class Output: 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, @@ -771,7 +772,7 @@ class Output: self.cache, {obj.hash_info}, shallow=False, - hardlink=False, + hardlink=hardlink, callback=cb, ) if relink: @@ -1399,12 +1400,14 @@ class Output: 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, )