[
https://issues.apache.org/jira/browse/IO-879?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gary D. Gregory resolved IO-879.
--------------------------------
Fix Version/s: 2.23.0
Resolution: Fixed
> 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
> Fix For: 2.23.0
>
>
> 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
(v10.3.26#10030026)