mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Fixed wait page after database rebuild, closes GH-59
This commit is contained in:
parent
3de4059f85
commit
7a3ee26c87
@ -43,7 +43,8 @@ def server_info():
|
|||||||
return {
|
return {
|
||||||
"name":settings.get_settings("NAME"),
|
"name":settings.get_settings("NAME"),
|
||||||
"version":version,
|
"version":version,
|
||||||
"versionstring":".".join(str(n) for n in version)
|
"versionstring":".".join(str(n) for n in version),
|
||||||
|
"db_status":dbstatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -257,6 +258,7 @@ def import_rulemodule(**keys):
|
|||||||
def rebuild(**keys):
|
def rebuild(**keys):
|
||||||
log("Database rebuild initiated!")
|
log("Database rebuild initiated!")
|
||||||
sync()
|
sync()
|
||||||
|
dbstatus['rebuildinprogress'] = True
|
||||||
from ..proccontrol.tasks.fixexisting import fix
|
from ..proccontrol.tasks.fixexisting import fix
|
||||||
fix()
|
fix()
|
||||||
global cla, coa
|
global cla, coa
|
||||||
|
@ -44,6 +44,10 @@ import urllib
|
|||||||
|
|
||||||
|
|
||||||
dblock = Lock() #global database lock
|
dblock = Lock() #global database lock
|
||||||
|
dbstatus = {
|
||||||
|
"healthy":False,
|
||||||
|
"rebuildinprogress":False
|
||||||
|
}
|
||||||
|
|
||||||
SCROBBLES = [] # Format: tuple(track_ref,timestamp,saved)
|
SCROBBLES = [] # Format: tuple(track_ref,timestamp,saved)
|
||||||
ARTISTS = [] # Format: artist
|
ARTISTS = [] # Format: artist
|
||||||
@ -747,6 +751,9 @@ def start_db():
|
|||||||
|
|
||||||
def build_db():
|
def build_db():
|
||||||
|
|
||||||
|
global dbstatus
|
||||||
|
dbstatus['healthy'] = False
|
||||||
|
dbstatus['rebuildinprogress'] = True
|
||||||
|
|
||||||
log("Building database...")
|
log("Building database...")
|
||||||
|
|
||||||
@ -810,6 +817,9 @@ def build_db():
|
|||||||
global ISSUES
|
global ISSUES
|
||||||
ISSUES = check_issues()
|
ISSUES = check_issues()
|
||||||
|
|
||||||
|
dbstatus['healthy'] = True
|
||||||
|
dbstatus['rebuildinprogress'] = False
|
||||||
|
|
||||||
log("Database fully built!")
|
log("Database fully built!")
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
console.log("Probing...");
|
console.log("Probing...");
|
||||||
pending = true;
|
pending = true;
|
||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
xhttp.open("GET","/apis/mlj_1/test", true);
|
xhttp.responseType = 'json';
|
||||||
|
xhttp.open("GET","/apis/mlj_1/serverinfo", true);
|
||||||
xhttp.onreadystatechange = goback;
|
xhttp.onreadystatechange = goback;
|
||||||
xhttp.send();
|
xhttp.send();
|
||||||
|
|
||||||
@ -26,15 +27,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function goback() {
|
function goback() {
|
||||||
if ((this.readyState == 4) && (this.status == 205)) {
|
if ((this.readyState == 4) && (this.status == 200)) {
|
||||||
console.log("Not ready yet!");
|
var response = this.response;
|
||||||
pending = false;
|
var status = response['db_status'];
|
||||||
}
|
console.log(response);
|
||||||
if ((this.readyState == 4) && (this.status == 204)) {
|
if (status['healthy'] && !status['rebuildinprogress']) {
|
||||||
console.log("K");
|
|
||||||
pending = false;
|
|
||||||
window.location = "/issues";
|
window.location = "/issues";
|
||||||
}
|
}
|
||||||
|
pending = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user