From 346e26433af3c6964d22cdce1280a4b2e2372b13 Mon Sep 17 00:00:00 2001 From: Terrtia Date: Mon, 15 Apr 2019 14:30:28 +0200 Subject: [PATCH] fix: [Update tags + UI] use srandmember + display update warning --- update/v1.4/Update-ARDB_Tags_background.py | 3 ++- var/www/modules/dashboard/Flask_dashboard.py | 8 +++++++- var/www/modules/dashboard/templates/index.html | 9 +++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/update/v1.4/Update-ARDB_Tags_background.py b/update/v1.4/Update-ARDB_Tags_background.py index 2dc050b7..ecd356ca 100755 --- a/update/v1.4/Update-ARDB_Tags_background.py +++ b/update/v1.4/Update-ARDB_Tags_background.py @@ -56,7 +56,7 @@ if __name__ == '__main__': nb_updated = 0 if total_to_update > 0: while tag_not_updated: - item_path = r_serv_tag.spop('maj:v1.5:absolute_path_to_rename') + item_path = r_serv_tag.srandmember('maj:v1.5:absolute_path_to_rename') old_tag_item_key = 'tag:{}'.format(item_path) new_item_path = item_path.replace(PASTES_FOLDER, '', 1) new_tag_item_key = 'tag:{}'.format(new_item_path) @@ -69,6 +69,7 @@ if __name__ == '__main__': else: progress = int((nb_updated * 100) /total_to_update) print('{}/{} Tags updated {}%'.format(nb_updated, total_to_update, progress)) + r_serv_tag.srem('maj:v1.5:absolute_path_to_rename', item_path) end = time.time() diff --git a/var/www/modules/dashboard/Flask_dashboard.py b/var/www/modules/dashboard/Flask_dashboard.py index fb59e96f..c4a272fc 100644 --- a/var/www/modules/dashboard/Flask_dashboard.py +++ b/var/www/modules/dashboard/Flask_dashboard.py @@ -22,6 +22,7 @@ cfg = Flask_config.cfg baseUrl = Flask_config.baseUrl r_serv = Flask_config.r_serv r_serv_log = Flask_config.r_serv_log +r_serv_db = Flask_config.r_serv_db max_dashboard_logs = Flask_config.max_dashboard_logs @@ -164,8 +165,13 @@ def index(): log_select.add(max_dashboard_logs) log_select = list(log_select) log_select.sort() + update_in_progress = False + if r_serv_db.exists('ail:update_v1.5'): + if not r_serv_db.exists('v1.5:onions') or not r_serv_db.exists('v1.5:metadata') or not r_serv_db.exists('v1.5:tags') or not r_serv_db.exists('v1.5:tags_background'): + update_in_progress = True + return render_template("index.html", default_minute = default_minute, threshold_stucked_module=threshold_stucked_module, - log_select=log_select, selected=max_dashboard_logs) + log_select=log_select, selected=max_dashboard_logs, update_in_progress=update_in_progress) # ========= REGISTRATION ========= app.register_blueprint(dashboard, url_prefix=baseUrl) diff --git a/var/www/modules/dashboard/templates/index.html b/var/www/modules/dashboard/templates/index.html index 6d1bf12d..11ed07a6 100644 --- a/var/www/modules/dashboard/templates/index.html +++ b/var/www/modules/dashboard/templates/index.html @@ -99,6 +99,14 @@ + {%if update_in_progress%} +
+ × + Warning! An Update is running on the background. Some informations like Tags, screenshot can be missing from the UI. + (Check Update Status) +
+ {%endif%} +
@@ -187,6 +195,7 @@
+