From 4a42403fb4bf27ba21f63b99c7cb75f9d13adfeb Mon Sep 17 00:00:00 2001
From: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
Date: Tue, 8 Nov 2022 16:33:30 +0100
Subject: [PATCH] Fallback to copying when hardlinking does not work

---
 samtools.wdl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/samtools.wdl b/samtools.wdl
index df712e5..587a53f 100644
--- a/samtools.wdl
+++ b/samtools.wdl
@@ -332,7 +332,7 @@ task Index {
         if [ ! -f ~{outputPath} ]
         then
             mkdir -p "$(dirname ~{outputPath})"
-            ln ~{bamFile} ~{outputPath}
+            ln ~{bamFile} ~{outputPath} || cp ~{bamFile} ~{outputPath}
         fi
         samtools index ~{outputPath} ~{bamIndexPath}
         '
@@ -531,7 +531,7 @@ task Tabix {
         mkdir -p "$(dirname ~{outputFilePath})"
         if [ ! -f ~{outputFilePath} ]
         then
-            ln ~{inputFile} ~{outputFilePath}
+            ln ~{inputFile} ~{outputFilePath} || cp ~{inputFile} ~{outputFilePath}
         fi
         tabix ~{outputFilePath} -p ~{type}
     }
-- 
GitLab