Skip to content
Snippets Groups Projects
Commit 7a070d42 authored by tpylak's avatar tpylak
Browse files

SE-48 report success even if ln reports failure if the exact copy exists

SVN: 6351
parent 63bb2ae0
No related branches found
No related tags found
No related merge requests found
...@@ -17,9 +17,11 @@ ...@@ -17,9 +17,11 @@
package ch.systemsx.cisd.common.utilities; package ch.systemsx.cisd.common.utilities;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogCategory;
...@@ -241,8 +243,22 @@ public final class RecursiveHardLinkMaker implements IPathImmutableCopier ...@@ -241,8 +243,22 @@ public final class RecursiveHardLinkMaker implements IPathImmutableCopier
{ {
public boolean run() public boolean run()
{ {
return ProcessExecutionHelper.runAndLog(cmd, singleFileLinkTimeout boolean result =
.getMillisToWaitForCompletion(), operationLog, machineLog); 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 = boolean ok =
...@@ -251,6 +267,20 @@ public final class RecursiveHardLinkMaker implements IPathImmutableCopier ...@@ -251,6 +267,20 @@ public final class RecursiveHardLinkMaker implements IPathImmutableCopier
return ok ? destFile : null; 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) private final List<String> createLnCmdLine(final File srcFile, final File destFile)
{ {
final List<String> tokens = new ArrayList<String>(); final List<String> tokens = new ArrayList<String>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment