[
https://issues.apache.org/jira/browse/IO-879?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18039994#comment-18039994
]
Gary D. Gregory commented on IO-879:
------------------------------------
Hi [~pkarwasz]
I added a comment in IO-878.
In this ticket, we should leave permissions as we found them, whether the API
succeeds or fails. That should not cause issues.
> Keep DOS `read-only` flag on `FileUtils.forceDelete` error
> ----------------------------------------------------------
>
> Key: IO-879
> URL: https://issues.apache.org/jira/browse/IO-879
> Project: Commons IO
> Issue Type: Bug
> Reporter: Piotr Karwasz
> Priority: Minor
>
> Deleting a file on Windows involves two steps:
> # Clear the DOS {{FILE_ATTRIBUTE_READONLY}} flag.
> # Call the Win32 {{DeleteFile}} function.
> This process is non-atomic and can partially fail. Clearing the flag does
> *not* guarantee that the user has permission to delete the file, since modern
> file systems enforce ACLs, not DOS attributes.
> *Problem*
> Both {{FileUtils.forceDelete}} and {{PathUtils.delete}} remove the DOS
> {{read-only}} flag before attempting deletion, but they *do not restore it*
> if the deletion fails. This leaves the file writable even though the delete
> did not succeed.
> *Why is this relevant?*
> Since JDK 25, {{File.delete}} no longer clears the DOS {{read-only}} flag
> automatically. Users looking for a drop-in replacement may turn to
> {{FileUtils.forceDelete}}, so it is important that its behavior is
> predictable and does not leave the file in a different state on failure.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)