Fixed backup issue.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user