[Minor] small error handling change in FileHelper
This commit is contained in:
parent
48e2defc9e
commit
4b179f8bb4
|
@ -244,7 +244,7 @@ public class FileHelper {
|
||||||
* The destination where to copy the files
|
* The destination where to copy the files
|
||||||
* @param checksum
|
* @param checksum
|
||||||
* if true, then a MD5 checksum is made to validate copying
|
* if true, then a MD5 checksum is made to validate copying
|
||||||
* @return <b>true</b> if and only if the renaming succeeded; <b>false</b> otherwise
|
* @return <b>true</b> if and only if the copying succeeded; <b>false</b> otherwise
|
||||||
*/
|
*/
|
||||||
public final static boolean copy(File[] srcFiles, File dstDirectory, boolean checksum) {
|
public final static boolean copy(File[] srcFiles, File dstDirectory, boolean checksum) {
|
||||||
|
|
||||||
|
@ -258,11 +258,16 @@ public class FileHelper {
|
||||||
File dstFile = new File(dstDirectory, srcFile.getName());
|
File dstFile = new File(dstDirectory, srcFile.getName());
|
||||||
if (srcFile.isDirectory()) {
|
if (srcFile.isDirectory()) {
|
||||||
dstFile.mkdir();
|
dstFile.mkdir();
|
||||||
if (!copy(srcFile.listFiles(), dstFile, checksum))
|
if (!copy(srcFile.listFiles(), dstFile, checksum)) {
|
||||||
|
String msg = "Failed to copy contents of {0} to {1}";
|
||||||
|
msg = MessageFormat.format(msg, srcFile.getAbsolutePath(), dstFile.getAbsolutePath());
|
||||||
|
logger.error(msg);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!copy(srcFile, dstFile, checksum))
|
if (!copy(srcFile, dstFile, checksum)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,8 +315,8 @@ public class FileHelper {
|
||||||
|
|
||||||
// cleanup if files are not the same length
|
// cleanup if files are not the same length
|
||||||
if (fromFile.length() != toFile.length()) {
|
if (fromFile.length() != toFile.length()) {
|
||||||
String msg = MessageFormat.format("Copying failed, as new files are not the same length: {0} / {1}", //$NON-NLS-1$
|
String msg = "Copying failed, as new files are not the same length: {0} / {1}";
|
||||||
fromFile.length(), toFile.length());
|
msg = MessageFormat.format(msg, fromFile.length(), toFile.length());
|
||||||
FileHelper.logger.error(msg);
|
FileHelper.logger.error(msg);
|
||||||
toFile.delete();
|
toFile.delete();
|
||||||
|
|
||||||
|
@ -319,8 +324,8 @@ public class FileHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
String msg = MessageFormat.format("Failed to copy path from {0} to + {1} due to:", fromFile, toFile);
|
||||||
FileHelper.logger.error(e.getMessage(), e);
|
FileHelper.logger.error(msg, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue