fix: [Update tags + UI] use srandmember + display update warning

This commit is contained in:
Terrtia 2019-04-15 14:30:28 +02:00
parent 3f1e68f638
commit 346e26433a
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
3 changed files with 18 additions and 2 deletions

View file

@ -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()

View file

@ -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)

View file

@ -99,6 +99,14 @@
</div>
</div>
{%if update_in_progress%}
<div class="alert alert-warning alert-dismissible fade in">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> An Update is running on the background. Some informations like Tags, screenshot can be <strong>missing from the UI</strong>.
(<a href="#">Check Update Status</a>)
</div>
{%endif%}
<div class="row">
<div class="col-lg-6">
<div class="panel panel-default">
@ -187,6 +195,7 @@
<!-- /#page-wrapper -->
</div>
<script> var url_showSavedPath = "{{ url_for('showsavedpastes.showsavedpaste') }}"; </script>
<script type="text/javascript" src="{{ url_for('static', filename='js/indexjavascript.js')}}"
data-urlstuff="{{ url_for('dashboard.stuff') }}" data-urllog="{{ url_for('dashboard.logs') }}">