https://bz.apache.org/bugzilla/show_bug.cgi?id=70157
Bug ID: 70157
Summary: Move task doesn't honor preserveLastModified=false
when renaming a directory; also some house-keeping
Product: Ant
Version: 1.10.17
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: Core
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
When using:
<move file="<dirA>" toFile="<dirB>" preserveLastModified="false" />
for a rename, when the code first tries this:
return sourceFile.renameTo(destFile);
in renameFile(), it lacks something like this afterwards:
boolean bResult = sourceFile.renameTo(destFile);
if (bResult && !preserveLastModified)
<touch>(destFile);
return bResult;
You can see a difference if you add:
filtering="true"
which in renameFile() fails-fast at the top and resorts to copyFile(), which
does honor the preserveLastModified.
-------
Side note, the methods:
renameFile()
copyFile()
moveFile()
should drop these parameters:
boolean filtering
boolean overwrite
as they already have access to the members:
protected boolean filtering = false;
protected boolean forceOverwrite = false;
As it is, the filtering parameter shadows the member, and the overwrite
parameter is seeded from the forceOverwrite member by callers:
renameFile() - uses filtering, doesn't use overwrite
copyFile() - uses filtering, doesn't use overwrite, uses forceOverwrite
moveFile() - uses filtering, uses overwrite, uses forceOverwrite
--
You are receiving this mail because:
You are the assignee for the bug.