return new Path(outputArchive, path);
}
private boolean copyFile(final Context context, final Path inputPath, final Path outputPath)
throws IOException {
FSDataInputStream in = openSourceFile(inputPath);
if (in == null) {
context.getCounter(Counter.MISSING_FILES).increment(1);
return false;
}
try {
// Verify if the input file exists
FileStatus inputStat = getFileStatus(inputFs, inputPath);
if (inputStat == null) return false;
// Verify if the output file exists and is the same that we want to copy
FileStatus outputStat = getFileStatus(outputFs, outputPath);
if (outputStat != null && sameFile(inputStat, outputStat)) {
LOG.info("Skip copy " + inputPath + " to " + outputPath + ", same file.");
return true;
}
context.getCounter(Counter.BYTES_EXPECTED).increment(inputStat.getLen());
// Ensure that the output folder is there and copy the file
outputFs.mkdirs(outputPath.getParent());
FSDataOutputStream out = outputFs.create(outputPath, true);
try {
if (!copyData(context, inputPath, in, outputPath, out, inputStat.getLen()))
return false;
} finally {
out.close();
}
// Preserve attributes
return preserveAttributes(outputPath, inputStat);
} finally {
in.close();
}
}