ShiguReader
ShiguReader copied to clipboard
avoid extracting the same file mulitple times when the user keeps sending the same request
const extractQueue = { };
//after 7zip
extractQueue[fileName] = true;
finally {
extractQueue[fileName] = false;
}
let timer;
let count = 0;
const time_out = 1000;
const max_wait_chokidir = 4;
function waitForExtract(){
checkCache
if have {
clearTimeout(timer)
send back
}else{
if(extractQueue[fileName] || count < max_wait_chokidir){
if(extractQueue[fileName]){
count++;
}
timer = setTimeOut(waitForExtract, time_out);
}else{
send 404
}
}
}
timer = setTimeOut(waitForExtract, time_out);