Skip to content

Commit 2a026c4

Browse files
committed
Fix bug preventing subsequent backups from being finished (temporary fix)
1 parent ff8cca8 commit 2a026c4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

blueprints/autobackup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def setup_backup_route(setup_state):
131131
setup_state.app.add_url_rule('/backup/start', view_func=login_required(backup))
132132

133133
def finish_backup():
134+
global statuses
134135
if Backup.get_or_none(Backup.is_finished == False) is None:
135136
# Don't think that this can actually happen but it's better to handle it regardless
136137
warning("No backups to finish!")
@@ -178,7 +179,7 @@ def finish_backup():
178179
backup_done_message += f"Kontrolní součet archivu je {hash}\n\n"
179180
backup_done_message += "Administrace Záznamů a Informační Bezpečnosti vám přeje hezký den!```" # Be polite :3
180181
webhook.send_text(backup_done_message)
181-
statuses.clear()
182+
statuses = {}
182183
Backup.update(is_finished=True).where(Backup.is_finished == False).execute()
183184

184185
@AutobackupController.route('/backups', methods=["GET"])
@@ -202,6 +203,9 @@ def backup_delete(backup_id: int):
202203
# TODO: 2FA
203204
info(f"Backup ID {backup_id} deleted by user {current_user.nickname} (ID: {current_user.id})")
204205
Backup.delete_by_id(backup_id)
206+
# TODO: Delete the actual archive
207+
# (Maybe schedule a task to purge deleted backups after some time to allow time for restore?)
208+
# Also add a confirmation dialog
205209
return redirect(url_for('AutobackupController.backup_index'))
206210

207211
@AutobackupController.route('/backup/<int:backup_id>/download')
@@ -277,6 +281,8 @@ def backup_status():
277281
statuses[tag].status.status = Status.Done
278282
statuses[tag].status.messages.append(current_message)
279283
if all([w.status.status == Status.Done for w in statuses.values()]):
284+
# TODO: This does not run after the first backup is done? Only fixed by a restart
285+
# Makes no sense since the dict is cleared in the finish_backup function
280286
info(f"Backup finished")
281287
finish_backup()
282288
case _:

0 commit comments

Comments
 (0)