[
https://issues.apache.org/jira/browse/IO-700?focusedWorklogId=534914&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-534914
]
ASF GitHub Bot logged work on IO-700:
-------------------------------------
Author: ASF GitHub Bot
Created on: 12/Jan/21 16:10
Start Date: 12/Jan/21 16:10
Worklog Time Spent: 10m
Work Description: garydgregory commented on a change in pull request #185:
URL: https://github.com/apache/commons-io/pull/185#discussion_r555848248
##########
File path: src/main/java/org/apache/commons/io/FileUtils.java
##########
@@ -2172,12 +2177,39 @@ public static void moveDirectoryToDirectory(final File
src, final File destDir,
* @since 1.4
*/
public static void moveFile(final File srcFile, final File destFile)
throws IOException {
+ moveFile(srcFile, destFile, true);
+ }
+
+ /**
+ * Moves a file.
+ * <p>
+ * When the destination file is on another file system, do a "copy and
delete".
+ * </p>
+ * <p>
+ * <strong>Note:</strong> Setting <code>preserveFileDate</code> to {@code
true} tries to preserve the files' last
+ * modified date/times using {@link File#setLastModified(long)} when
destination is another file system, however it
+ * is not guaranteed that those operations will succeed. If the
modification operation fails, the methods throws
+ * IOException.
+ * </p>
+ *
+ * @param srcFile the file to be moved.
+ * @param destFile the destination file.
+ * @param preserveFileDate true if the file date of the "copy and delete"
should be the same as the original when
+ * destination is on another file system. Param is not used if
destination is on same file system.
+ * @throws NullPointerException if any of the given {@code File}s are
{@code null}.
+ * @throws FileExistsException if the destination file exists.
+ * @throws IOException if source or destination is invalid.
+ * @throws IOException if an error occurs or setting the last-modified
time didn't succeeded.
+ * @since 1.4
Review comment:
This is a new method for 2.9.0, please adjust the since tag.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 534914)
Time Spent: 50m (was: 40m)
> Provide FileUtils.moveFile(srcFile, dstFile, preserveFileDate)
> --------------------------------------------------------------
>
> Key: IO-700
> URL: https://issues.apache.org/jira/browse/IO-700
> Project: Commons IO
> Issue Type: Bug
> Affects Versions: 2.8.0
> Reporter: tza
> Priority: Major
> Time Spent: 50m
> Remaining Estimate: 0h
>
> The current implementation 2.8.0 throws an Exception, if moveFiles or
> copyFiles (with preserveFileDate=true) cannot update the lastModifiedDate.
> This was not the case in 2.6.
>
> For FileUtils.moveFile the copyFile(File, File) method is used, which results
> in a copy with preserveFileDate=true. Could you provide a method overload to
> moveFile similiar to copyFile.
>
> {code:java}
> public static void moveFile(final File srcFile, final File destFile) throws
> IOException {
> moveFile(srcFile, destFile, true);
> }
> public static void moveFile(final File srcFile, final File destFile, boolean
> preserveFileDate) throws IOException {
> ...
> copyFile(srcFile, destFile, preserveFileDate);
> }
> {code}
>
> (We have a cifs mount where the server is not allowing the update)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)