Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8289058

(fs) Deleting directory is unreliable when Finder creates .DS_Store files (macOS)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • tbd
    • 18
    • core-libs
    • None

        Deletion of a file directory on macOS is unreliable. This problem is typically seen when deleting a file tree. The symptom of the problem is a failure to delete a directory after deleting the directory contents. The reported failure is that the directory is not empty. The directory is not empty because it contains a .DS_Store file created by the Finder using a background thread that is triggered by FSEvents. This Finder behavior is enabled by viewing an ancestor directory with the Calculate All Sizes view option enabled. The .DS_Store file is used to cache the cumulative size of each directory in the viewed tree.

        One could rightly call this behavior a macOS bug. It affects even basic Unix commands such as rm -rf. However, this behavior has existed for many years (it was reported in 2013, see linked issue) and there is no sign of the problem being fixed anytime soon.

        A suggested workaround is to consider a .DS_Store file a "special file" whose existence does not make the directory "non empty" for the purpose of directory deletion. This change would need to be implemented in the JDK because it is not implemented by the file system.

              bpb Brian Burkhalter
              alans Alan Snyder
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: