You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/18 16:15:56 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #12848: ARROW-16159: [C++][Python] Allow FileSystem::DeleteDirContents to succeed if the directory is missing

pitrou commented on code in PR #12848:
URL: https://github.com/apache/arrow/pull/12848#discussion_r852230370


##########
python/pyarrow/fs.py:
##########
@@ -346,18 +346,24 @@ def create_dir(self, path, recursive):
     def delete_dir(self, path):
         self.fs.rm(path, recursive=True)
 
-    def _delete_dir_contents(self, path):
-        for subpath in self.fs.listdir(path, detail=False):
+    def _delete_dir_contents(self, path, missing_dir_ok):
+        try:
+            subpaths = self.fs.listdir(path, detail=False)
+        except FileNotFoundError:
+            if missing_dir_ok:
+                return
+            raise
+        for subpath in subpaths:
             if self.fs.isdir(subpath):
                 self.fs.rm(subpath, recursive=True)
             elif self.fs.isfile(subpath):
                 self.fs.rm(subpath)
 
-    def delete_dir_contents(self, path):
+    def delete_dir_contents(self, path, missing_dir_ok):

Review Comment:
   I don't think either approach you suggest is better than the explicit compatibility breakage. This is indeed an annoyance for third-party implementations, but there are probably not many of them, and their authors should be competent enough to write the necessary compatibility handling code if required (basically by inspecting the PyArrow version).



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org