guard call to stat() against ENOENT
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Thu, 5 Jul 2018 08:54:31 +0000 (10:54 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Sat, 1 Feb 2020 14:14:06 +0000 (15:14 +0100)
Move the implicit call to stat(2) into the ENOENT-safe block we
just introduced.

Found by unit testing.

deltatar/deltatar.py

index 161008c..03de734 100644 (file)
@@ -733,14 +733,14 @@ class DeltaTar(object):
 
         # for each file to be in the backup, do:
         for path in self._recursive_walk_dir('.'):
-            # calculate stat dict for current file
-            statd = self._stat_dict(path)
-            statd['path'] = u'snapshot://' + statd['path']
-            statd['volume'] = self.vol_no
-
-            # backup file
 
             try: # backup file
+                # calculate stat dict for current file
+                statd = self._stat_dict(path)
+                statd['path'] = u'snapshot://' + statd['path']
+                statd['volume'] = self.vol_no
+
+                # backup file
                 tarobj.add(path, arcname = statd['path'], recursive=False)
             except FileNotFoundError as exn:
                 # file vanished since the call to access(3) above