diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMaker.java b/common/source/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMaker.java index 8ed8de65bfb0917d2eed44d515a3b897f17e6d81..49f7e3b28867e5a276070b08a86bce06bf10d864 100644 --- a/common/source/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMaker.java +++ b/common/source/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMaker.java @@ -17,9 +17,11 @@ package ch.systemsx.cisd.common.utilities; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; +import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import ch.systemsx.cisd.common.logging.LogCategory; @@ -241,8 +243,22 @@ public final class RecursiveHardLinkMaker implements IPathImmutableCopier { public boolean run() { - return ProcessExecutionHelper.runAndLog(cmd, singleFileLinkTimeout - .getMillisToWaitForCompletion(), operationLog, machineLog); + boolean result = + ProcessExecutionHelper.runAndLog(cmd, singleFileLinkTimeout + .getMillisToWaitForCompletion(), operationLog, machineLog); + // NOTE: we have noticed that sometimes the result is false although the file + // have been copied + if (result == false && destFile.exists() + && checkIfIdenticalContent(file, destFile)) + { + machineLog + .warn("Link creator reported failure, but the exact copy of the file '" + + file.getPath() + + "' seems to exist in '" + + destFile.getPath() + "'. Error will be ignored."); + result = true; + } + return result; } }; boolean ok = @@ -251,6 +267,20 @@ public final class RecursiveHardLinkMaker implements IPathImmutableCopier return ok ? destFile : null; } + private static boolean checkIfIdenticalContent(final File file1, final File file2) + { + try + { + return FileUtils.contentEquals(file1, file2); + } catch (IOException e) + { + machineLog + .warn("It was not possible to compare the content of the file to check if creating links worked: " + + e.getMessage()); + } + return false; + } + private final List<String> createLnCmdLine(final File srcFile, final File destFile) { final List<String> tokens = new ArrayList<String>();