From 2afb57a6cc80e3c286801cab7c469daa7405c823 Mon Sep 17 00:00:00 2001 From: lwark Date: Thu, 15 Aug 2024 12:41:22 -0500 Subject: [PATCH] Fixed backup issue. --- CHANGELOG.md | 4 ++++ src/submissions/frontend/widgets/app.py | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a438820..723b212 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 202408.03 + +- Fixed issue backing up database file. + ## 202407.05 - Fixed issue with scrolling form potentially altering combobox values. diff --git a/src/submissions/frontend/widgets/app.py b/src/submissions/frontend/widgets/app.py index 02e7d38..17131ec 100644 --- a/src/submissions/frontend/widgets/app.py +++ b/src/submissions/frontend/widgets/app.py @@ -181,15 +181,16 @@ class App(QMainWindow): """ month = date.today().strftime("%Y-%m") current_month_bak = Path(self.ctx.backup_path).joinpath(f"submissions_backup-{month}").resolve() - # logger.debug(f"Here is the db directory: {self.ctx.database_path}") - # logger.debug(f"Here is the backup directory: {self.ctx.backup_path}") + logger.debug(f"Here is the db directory: {self.ctx.database_path}") + logger.debug(f"Here is the backup directory: {self.ctx.backup_path}") match self.ctx.database_schema: case "sqlite": + db_path = self.ctx.database_path.joinpath(self.ctx.database_name).with_suffix(".db") current_month_bak = current_month_bak.with_suffix(".db") - if not current_month_bak.exists() and "demo" not in self.ctx.database_path.__str__(): + if not current_month_bak.exists() and "Archives" not in db_path.__str__(): logger.info("No backup found for this month, backing up database.") try: - shutil.copyfile(self.ctx.backup_path, current_month_bak) + shutil.copyfile(db_path, current_month_bak) except PermissionError as e: logger.error(f"Couldn't backup database due to: {e}") case "postgresql+psycopg2": @@ -197,7 +198,6 @@ class App(QMainWindow): current_month_bak = current_month_bak.with_suffix(".psql") - class AddSubForm(QWidget): def __init__(self, parent:QWidget):