From e76ca7e08fcd8adba1e2507e66905c100a5af0d4 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 5 Jul 2018 11:57:27 +0200 Subject: [PATCH] fix incorrect error handling in deltatar 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 | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/deltatar/deltatar.py b/deltatar/deltatar.py index 03de734..460d274 100644 --- a/deltatar/deltatar.py +++ b/deltatar/deltatar.py @@ -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: -- 1.7.1