Fixed backup issue.
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
## 202408.03
|
||||||
|
|
||||||
|
- Fixed issue backing up database file.
|
||||||
|
|
||||||
## 202407.05
|
## 202407.05
|
||||||
|
|
||||||
- Fixed issue with scrolling form potentially altering combobox values.
|
- Fixed issue with scrolling form potentially altering combobox values.
|
||||||
|
|||||||
@@ -181,15 +181,16 @@ class App(QMainWindow):
|
|||||||
"""
|
"""
|
||||||
month = date.today().strftime("%Y-%m")
|
month = date.today().strftime("%Y-%m")
|
||||||
current_month_bak = Path(self.ctx.backup_path).joinpath(f"submissions_backup-{month}").resolve()
|
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 db directory: {self.ctx.database_path}")
|
||||||
# logger.debug(f"Here is the backup directory: {self.ctx.backup_path}")
|
logger.debug(f"Here is the backup directory: {self.ctx.backup_path}")
|
||||||
match self.ctx.database_schema:
|
match self.ctx.database_schema:
|
||||||
case "sqlite":
|
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")
|
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.")
|
logger.info("No backup found for this month, backing up database.")
|
||||||
try:
|
try:
|
||||||
shutil.copyfile(self.ctx.backup_path, current_month_bak)
|
shutil.copyfile(db_path, current_month_bak)
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
logger.error(f"Couldn't backup database due to: {e}")
|
logger.error(f"Couldn't backup database due to: {e}")
|
||||||
case "postgresql+psycopg2":
|
case "postgresql+psycopg2":
|
||||||
@@ -197,7 +198,6 @@ class App(QMainWindow):
|
|||||||
current_month_bak = current_month_bak.with_suffix(".psql")
|
current_month_bak = current_month_bak.with_suffix(".psql")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AddSubForm(QWidget):
|
class AddSubForm(QWidget):
|
||||||
|
|
||||||
def __init__(self, parent:QWidget):
|
def __init__(self, parent:QWidget):
|
||||||
|
|||||||
Reference in New Issue
Block a user