fix incorrect error handling in deltatar
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Thu, 5 Jul 2018 09:57:27 +0000 (11:57 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Sat, 1 Feb 2020 14:14:06 +0000 (15:14 +0100)
Account for the fact that the os library converts return values
to exceptions ... It is not documented whether os.open() can ever
return negative values at all.

deltatar/deltatar.py

index 03de734..460d274 100644 (file)
@@ -445,8 +445,12 @@ class DeltaTar(object):
         while queue:
             cur_path = queue.pop(0)
 
-            dfd = os.open (cur_path, os.O_DIRECTORY)
-            if dfd == -1: # it might have been removed in the meantime
+            try:
+                dfd = os.open (cur_path, os.O_DIRECTORY)
+            except FileNotFoundError as exn:
+                self.logger.warning ("failed to open entity [%s] as directory; "
+                                     "file system (error: %s); skipping"
+                                     % (cur_path, str (exn)))
                 continue
 
             try: