From c7fdf56264781116b80d46f2087e0150db8fb423 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 17 Dec 2025 17:53:41 +0000 Subject: store: Do not attempt to predict when hard linking will fail. Do not attempt to predict the exact conditions when hard linking will fail. Just try to hard link first, and fall back to copying when it fails. Predicting the exact conditions is complicated, and may not port well. --- ravanan/store.scm | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/ravanan/store.scm b/ravanan/store.scm index a52bb50..f96354b 100644 --- a/ravanan/store.scm +++ b/ravanan/store.scm @@ -117,20 +117,12 @@ already exists, do nothing." ".stderr")) store)) -(define (same-filesystem? path1 path2) - "Return @code{#t} if @var{path1} and @var{path2} are on the same filesystem. -Else, return @code{#f}." - (= (stat:dev (stat path1)) - (stat:dev (stat path2)))) - (define (link-or-copy source destination) "Hard link @var{source} to @var{destination} if possible. Else, copy it." - ;; Hard link if the source file is on the same filesystem as the destination - ;; directory. Else, copy. - ((if (same-filesystem? source (dirname destination)) - link - copy-file) - source destination)) + ;; Hard linking can sometimes fail (when files are on different filesystems, + ;; different mounts, etc.). In such cases, fall back to copying. + (or (false-if-exception (link source destination)) + (copy-file source destination))) (define (intern-file file store) "Intern @code{File} type object @var{file} into the ravanan @var{store} unless it -- cgit 1.4.1