[
https://issues.apache.org/jira/browse/IO-721?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17331273#comment-17331273
]
Darius Cooper commented on IO-721:
----------------------------------
Looking at the diff between 2.7 and 2.8.0
This code: destDir.setLastModified(srcDir.lastModified());
was replaced by
{code:java}
private static void setLastModified(final File sourceFile, final File
targetFile) throws IOException {
if (!targetFile.setLastModified(sourceFile.lastModified())) {
throw new IOException("Failed setLastModified on " + sourceFile);
}
}{code}
thus throwing an IOException in a situation where it previously did not.
There are comments in the code that show this was intentional.
It seems that the work-around (which would work in both 2.7 and 2.8.0) is to
call the overriddedn copyDirectory() method, and explicitly pass
pass
{noformat}
preserveFileDate=false{noformat}
> FileUtils.copyDirectory() tries to set last modified on source dir after
> update to 2.8.0
> ----------------------------------------------------------------------------------------
>
> Key: IO-721
> URL: https://issues.apache.org/jira/browse/IO-721
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.8.0
> Environment: Ubuntu 20.04 LTS
> Groovy 3.0.x
> Java 11 (from Ubuntu packages)
> Reporter: Dirk Heinrichs
> Priority: Major
>
> A simple
> {code:java}
> FileUtils.copyDirectory(source, dest, glob) {code}
> works fine when using Commons-IO 2.7, but fails with
> {code:java}
> Caught: java.io.IOException: Failed setLastModified on /path/to/source
> java.io.IOException: Failed setLastModified on /path/to/source
> at
> org.apache.commons.io.FileUtils.setLastModified(FileUtils.java:2561)
> at
> org.apache.commons.io.FileUtils.doCopyDirectory(FileUtils.java:1361)
> at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:733)
> at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:659)
> at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:606)
> {code}
> after update to 2.8.0. From reading the documentation, it's also my
> understanding that "setLastModified()" should be executed on "dest" to set
> the same modification time as "source", but *not* on "source".
--
This message was sent by Atlassian Jira
(v8.3.4#803005)