On Mon, Aug 10, 2020 at 8:00 PM Gary Gregory <garydgreg...@gmail.com> wrote:
> On Mon, Aug 10, 2020 at 7:45 PM sebb <seb...@gmail.com> wrote: > >> On Tue, 11 Aug 2020 at 00:19, Gary Gregory <garydgreg...@gmail.com> >> wrote: >> > >> > On Mon, Aug 10, 2020 at 5:35 PM sebb <seb...@gmail.com> wrote: >> > >> > > On Mon, 10 Aug 2020 at 21:51, Gary Gregory <garydgreg...@gmail.com> >> wrote: >> > > > >> > > > On Sun, Aug 9, 2020 at 7:07 AM sebb <seb...@gmail.com> wrote: >> > > > >> > > > > On Fri, 7 Aug 2020 at 19:29, <ggreg...@apache.org> wrote: >> > > > > > >> > > > > > This is an automated email from the ASF dual-hosted git >> repository. >> > > > > > >> > > > > > ggregory pushed a commit to branch master >> > > > > > in repository >> https://gitbox.apache.org/repos/asf/commons-io.git >> > > > > > >> > > > > > >> > > > > > The following commit(s) were added to refs/heads/master by this >> push: >> > > > > > new 9407c2a 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. >> > > > > > 9407c2a is described below >> > > > > >> > > > > -1 >> > > > > >> > > > > We should not change the generated file date unless >> preserveFileDate is >> > > > > true. >> > > > > >> > > > > As it is now, the target file will be created with an OS-provided >> > > > > modification time, which is then overridden by an arbitrary >> timestamp >> > > > > some time in the future. >> > > > > >> > > > > That seems wrong, and changes the existing behaviour. >> > > > > >> > > > >> > > > Please review git master for my latest. >> > > >> > > OK, that part now looks OK. >> > > >> > > However both doCopyFile and doCopyDirectory now return a boolean value >> > > which is never used. >> > > Why is that? >> > > >> > >> > Both methods _do_ use this flag. >> >> Huh? >> The methods return a boolean value which is not used by the callers. >> > > Ah, right, I misread your message, you're talking about _return_ values. > > Yeah, well, I'm not sure what's worse: > > 1) Propagating the return value of setLastModifed() to call sites, which > feels C-like and wrong instead of throwing an Exception. > 2) Convert the result of setLastModifed() where it is called to an > IOException; which feels more Java-like. > I implemented (2) and I feel the code is much better. Gary > 3) Something else. > > WDYT? > > Gary > > >> > Gary >> > >> > >> > > >> > > > Thank you Sebb! >> > > > Gary >> > > > >> > > > >> > > > > >> > > > > > commit 9407c2af641e81a16f9c4339b2dcf5a314897ed9 >> > > > > > Author: Gary Gregory <gardgreg...@gmail.com> >> > > > > > AuthorDate: Fri Aug 7 14:29:05 2020 -0400 >> > > > > > >> > > > > > 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. >> > > > > > --- >> > > > > > src/main/java/org/apache/commons/io/FileUtils.java | 7 ++----- >> > > > > > 1 file changed, 2 insertions(+), 5 deletions(-) >> > > > > > >> > > > > > diff --git a/src/main/java/org/apache/commons/io/FileUtils.java >> > > > > b/src/main/java/org/apache/commons/io/FileUtils.java >> > > > > > index 7bee5bf..61b1541 100644 >> > > > > > --- a/src/main/java/org/apache/commons/io/FileUtils.java >> > > > > > +++ b/src/main/java/org/apache/commons/io/FileUtils.java >> > > > > > @@ -1387,7 +1387,7 @@ public class FileUtils { >> > > > > > * position >> > > > > > */ >> > > > > > private static boolean doCopyFile(final File srcFile, >> final File >> > > > > destFile, final boolean preserveFileDate, CopyOption... >> copyOptions) >> > > > > > - throws IOException { >> > > > > > + throws IOException { >> > > > > > if (destFile.exists() && destFile.isDirectory()) { >> > > > > > throw new IOException("Destination '" + destFile + >> "' >> > > > > exists but is a directory"); >> > > > > > } >> > > > > > @@ -1401,10 +1401,7 @@ public class FileUtils { >> > > > > > // TODO IO-386: Do we still need this check? >> > > > > > checkEqualSizes(srcFile, destFile, srcFile.length(), >> > > > > destFile.length()); >> > > > > > >> > > > > > - if (preserveFileDate) { >> > > > > > - return >> destFile.setLastModified(srcFile.lastModified()); >> > > > > > - } >> > > > > > - return true; >> > > > > > + return destFile.setLastModified(preserveFileDate ? >> > > > > srcFile.lastModified() : System.currentTimeMillis()); >> > > > > > } >> > > > > > >> > > > > > >> > > > > >> > > >> //----------------------------------------------------------------------- >> > > > > > >> > > > > >> > > > > >> --------------------------------------------------------------------- >> > > > > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org >> > > > > For additional commands, e-mail: dev-h...@commons.apache.org >> > > > > >> > > > > >> > > >> > > --------------------------------------------------------------------- >> > > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org >> > > For additional commands, e-mail: dev-h...@commons.apache.org >> > > >> > > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org >> For additional commands, e-mail: dev-h...@commons.apache.org >> >>