Added check for existance of database before attempting backup

This commit is contained in:
Linus2punkt0
2023-09-12 22:54:58 +02:00
parent f5330e5a49
commit 208d58fd4d

View File

@@ -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):