garydgregory commented on PR #881:
URL: https://github.com/apache/commons-io/pull/881#issuecomment-6729645446

   @efegokdemir 
   Thank you for working on IO-879. Restoring the read-only attribute after a 
failed deletion is the right direction. However, I’m closing this PR in favor 
of PR #927 that addresses several correctness and testing issues:
   
   1) The Windows tests do not reliably cause deletion to fail. They mark the 
parent directory DOS read-only, but Windows [does not honor that attribute on 
directories](https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants).
 That setup does not establish the failure needed to test restoration.
   
   2) Restoration can change POSIX file permissions. The new `isReadOnly()` 
treats missing `OWNER_WRITE` as read-only, then calls `setReadOnly(file, 
true)`. That method also adds `OWNER_READ`, potentially granting a permission 
the file did not originally have.
   
   3) Restoring parent permissions after each visitor deletion can interrupt 
traversal. A parent can become non-writable before a later child directory is 
deleted, causing `AccessDeniedException`. I reproduced this behavior and added 
a regression test.
   
   4) Attribute-read failures can leave the original problem unresolved. The 
attribute-reading helpers swallow `IOException`, so deletion may clear the DOS 
flag without having saved its original value.
   
   PR #927 reuses DOS restoration logic across the deletion paths, preserves 
existing POSIX traversal behavior, and avoids clearing DOS state when its 
original value cannot be read. The tests in PR #927 verify that the flag is 
cleared during the failing deletion attempt and restored afterward.
   
   Thank you again for the contribution and for helping move this issue forward.
   


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