From 208d58fd4d0947e7d2c2f9147be3b711e4bcb5ad Mon Sep 17 00:00:00 2001 From: Linus2punkt0 Date: Tue, 12 Sep 2023 22:54:58 +0200 Subject: [PATCH] Added check for existance of database before attempting backup --- crosspost.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crosspost.py b/crosspost.py index f7f64ef..5ee557e 100644 --- a/crosspost.py +++ b/crosspost.py @@ -496,7 +496,8 @@ def countLines(file): # and before the live database is saved as a backup, the current backup is saved as a new file, so that # it can be recovered later. def dbBackup(): - if os.path.isfile(backupPath) and datetime.fromtimestamp(os.stat(backupPath).st_mtime) > datetime.now() - timedelta(hours = 24): + if not os.path.isfile(databasePath) or (os.path.isfile(backupPath) + and datetime.fromtimestamp(os.stat(backupPath).st_mtime) > datetime.now() - timedelta(hours = 24)): return if os.path.isfile(backupPath): if countLines(backupPath) < countLines(databasePath):