Skip to content

Commit 9407c2a

Browse files
author
Gary Gregory
committed
Since the default behavior of file copying of attributes is OS
dependent, we give the new target file the current timestamp when preserveFileDate is false.
1 parent 2d3f67c commit 9407c2a

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/main/java/org/apache/commons/io/FileUtils.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ private static boolean doCopyDirectory(final File srcDir, final File destDir, fi
13871387
* position
13881388
*/
13891389
private static boolean doCopyFile(final File srcFile, final File destFile, final boolean preserveFileDate, CopyOption... copyOptions)
1390-
throws IOException {
1390+
throws IOException {
13911391
if (destFile.exists() && destFile.isDirectory()) {
13921392
throw new IOException("Destination '" + destFile + "' exists but is a directory");
13931393
}
@@ -1401,10 +1401,7 @@ private static boolean doCopyFile(final File srcFile, final File destFile, final
14011401
// TODO IO-386: Do we still need this check?
14021402
checkEqualSizes(srcFile, destFile, srcFile.length(), destFile.length());
14031403

1404-
if (preserveFileDate) {
1405-
return destFile.setLastModified(srcFile.lastModified());
1406-
}
1407-
return true;
1404+
return destFile.setLastModified(preserveFileDate ? srcFile.lastModified() : System.currentTimeMillis());
14081405
}
14091406

14101407
//-----------------------------------------------------------------------

0 commit comments

Comments
 (0)