Fixed backup issue.

This commit is contained in:
lwark
2024-08-15 12:41:22 -05:00
parent 6c0795e92e
commit 2afb57a6cc
2 changed files with 9 additions and 5 deletions

View File

@@ -1,3 +1,7 @@
## 202408.03
- Fixed issue backing up database file.
## 202407.05
- Fixed issue with scrolling form potentially altering combobox values.

View File

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