fixed some stuff, caching may still be broken

This commit is contained in:
Daniel Sommer 2022-02-11 01:13:51 +01:00
parent adb597e83b
commit 0520d24e29
3 changed files with 11 additions and 7 deletions

View file

@ -5,7 +5,7 @@
"timestamp": "DD.MM.YYYY HH:mm:ss:SS"
},
"cache": {
"active": true,
"active": false,
"lifetime": 15
},
"log": {

View file

@ -235,6 +235,7 @@ function parseCurrentPedalboard(currentPedalboard) {
return new Promise(function (resolve, reject) {
getDefaultPedalboard()
.then(function (defaultPedalboard) {
test = defaultPedalboard;
currentPedals = [];
if (defaultPedalboard.id == currentPedalboard.id) {
return resolve(currentPedals);
@ -366,11 +367,13 @@ function setPedalboard(pedalboard) {
if (!pedalboard || !pedalboard.bundle) {
return reject('error: no bundle set for pedalboard');
}
var tmpPedalboard;
getCurrentPedalboard()
.then(function (currentPedalboard) {
if (pedalboard.id == currentPedalboard.id) {
return Promise.reject('pedalboard \'' + pedalboard.id + '\' is already active');
}
tmpPedalboard = currentPedalboard;
})
.then(function () {
return reset()
@ -379,8 +382,7 @@ function setPedalboard(pedalboard) {
return util.httpPOST(config.modep.host, config.modep.port, '/pedalboard/load_bundle/?bundlepath=' + pedalboard.bundle)
})
.then(function () {
currentPedalboard = pedalboard
parseCurrentPedalboard(currentPedalboard)
parseCurrentPedalboard(tmpPedalboard);
})
.then(resolve)
.catch(reject);

View file

@ -56,7 +56,7 @@ function handleRequests() {
if (code == undefined) {
code = 500;
}
endRequest(request, response, code, err);
endRequest(request, response, err, code);
});
});
}
@ -70,9 +70,11 @@ function endRequest(request, response, msg, code) {
code: code
}
if (msg != undefined) {
try {
if (msg instanceof Object) {
object.data = JSON.stringify(msg);
} catch {
} else if (msg instanceof Error) {
object.data = msg.toString();
} else {
object.data = msg;
}
}