ppkarwasz opened a new pull request, #791:
URL: https://github.com/apache/commons-io/pull/791

   On Windows, the `DeleteFile` Win32 API has a little quirk: it refuses to 
delete files with the legacy **DOS read-only attribute** set. (Because 
apparently 99% of Windows users don’t realize that “deleting a file” is 
actually an operation on the *directory*, not the file itself 😉).
   
   So the usual drill is: clear the read-only flag first, then delete.
   
   * Until JDK 25, `File.delete()` did this for you behind the scenes: it 
quietly stripped the flag before calling into `DeleteFile`. That meant your 
file might be left behind (with the flag missing) if the *real* ACLs didn’t 
allow deletion.
   * From JDK 25 onward, `File.delete()` doesn’t touch the flag anymore. If the 
bit is set, `DeleteFile` fails, end of story.
   * `FileUtils.forceDelete()` already knows how to juggle the flag itself, so 
its behavior didn’t change.
   
   This PR:
   
   * Updates two tests that were (unfairly) comparing `File.delete` with 
`FileUtils.forceDelete`. With JDK 25, their expectations diverged.
   * Adds a new test to confirm that `FileUtils.forceDelete` restores the 
read-only flag if the actual deletion fails.
   
   > [!WARNING]
   > I didn’t develop this on a Windows box, so I couldn’t test it locally. 
Leaving this as a **draft PR** until CI tells us whether Windows agrees with me.
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to