@@ -131,7 +131,6 @@ def setup_backup_route(setup_state):
131131 setup_state .app .add_url_rule ('/backup/start' , view_func = login_required (backup ))
132132
133133def finish_backup ():
134- global statuses
135134 if Backup .get_or_none (Backup .is_finished == False ) is None :
136135 # Don't think that this can actually happen but it's better to handle it regardless
137136 warning ("No backups to finish!" )
@@ -179,7 +178,7 @@ def finish_backup():
179178 backup_done_message += f"Kontrolní součet archivu je { hash } \n \n "
180179 backup_done_message += "Administrace Záznamů a Informační Bezpečnosti vám přeje hezký den!```" # Be polite :3
181180 webhook .send_text (backup_done_message )
182- statuses = {}
181+ statuses . clear ()
183182 Backup .update (is_finished = True ).where (Backup .is_finished == False ).execute ()
184183
185184@AutobackupController .route ('/backups' , methods = ["GET" ])
@@ -259,7 +258,8 @@ def backup_status():
259258 if backup_phase == Status .PagesMain :
260259 statuses [tag ].status .finished_articles = message ['done' ]
261260 statuses [tag ].status .postponed_articles = message ['postponed' ]
262- statuses [tag ].status .status = backup_phase
261+ if statuses [tag ].status .status != Status .Done :
262+ statuses [tag ].status .status = backup_phase
263263 current_message .status = backup_phase
264264 statuses [tag ].status .messages .append (current_message )
265265 case MessageType .ErrorFatal :
@@ -280,6 +280,8 @@ def backup_status():
280280 with statuses [tag ].mutex :
281281 statuses [tag ].status .status = Status .Done
282282 statuses [tag ].status .messages .append (current_message )
283+ # for w in list(statuses.values()):
284+ # debug(f"Tag: {w.status.wiki_tag}; Status: {w.status.status}; Finished: {w.status.finished_articles}; Total: {w.status.total_articles}; Errors: {w.status.total_errors}; Last message: {w.status.messages[-1]}")
283285 if all ([w .status .status == Status .Done for w in statuses .values ()]):
284286 # TODO: This does not run after the first backup is done? Only fixed by a restart
285287 # Makes no sense since the dict is cleared in the finish_backup function
0 commit comments