From 161f018cb9fd5eb08ab11a3ff10c9e3cdfd7e4f5 Mon Sep 17 00:00:00 2001 From: server Date: Sun, 29 Sep 2024 20:13:10 -0700 Subject: [PATCH] Bugfix attempt: When a file disappears before its ctime can be checked, don't let the whole program crash --- domain/BackupRotator.py | 7 ++++++- domain/Util.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/domain/BackupRotator.py b/domain/BackupRotator.py index 8079c20..b41fdda 100755 --- a/domain/BackupRotator.py +++ b/domain/BackupRotator.py @@ -326,7 +326,12 @@ class BackupRotator: best_ctime = None for item in items: - ctime = Util.detect_item_creation_date(config, item) + try: + ctime = Util.detect_item_creation_date(config, item) + except FileNotFoundError as e: + self.__logger.error(f"File disappeared while trying to check ctime: {item}") + continue + if best_ctime is None or ctime < best_ctime: best_ctime = ctime best_item = item diff --git a/domain/Util.py b/domain/Util.py index a8de25e..92579e0 100644 --- a/domain/Util.py +++ b/domain/Util.py @@ -42,6 +42,8 @@ class Util: # print("got mtime") stat = item.stat().st_birthtime # print("got btime") + except FileNotFoundError as e: + raise e except AttributeError: pass