ShiguReader icon indicating copy to clipboard operation
ShiguReader copied to clipboard

avoid extracting the same file mulitple times when the user keeps sending the same request

Open hjyssg opened this issue 4 years ago • 1 comments

const  extractQueue = {  };

//after 7zip
extractQueue[fileName] = true;


finally {
	extractQueue[fileName] = false;
}

hjyssg avatar Apr 23 '20 07:04 hjyssg

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

hjyssg avatar Apr 23 '20 07:04 hjyssg