Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
My understanding is that Things[fileRepositoryThing].ExtractArchive(params) is an asynchronous function. Is there an event listener service similar to addEventListener( ) that I can use to run a callback function when the extraction is complete?
I am moving the file after it's extracted, but I want to make the process more efficient by using some kind of event listener instead of a do while loop.
let moveFileComplete = false;
do {
try {
Things["SystemRepository"].MoveFile({
targetPath: "/Push/" + me.name + "/" + fileName /* STRING */ ,
overwrite: true /* BOOLEAN */ ,
sourcePath: "/temp/Push/" + fileName /* STRING */
});
moveFileComplete = true;
} catch (err) {
moveFileComplete = false;
pause(29999); //pause to ensure file extraction is complete before restarting loop
}
} while (!moveFileComplete);
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
Solved! Go to Solution.
Hi @Willie ,
The ExtractArchive method is not asynchronous (at least in 9.3.4). Can you please let me know where you have observed this statement in our documentation? We need to correct this.
I've just extracted a 3,4GB file and the method was correctly blocking as expected until it finished extraction.
Hi @Willie ,
The ExtractArchive method is not asynchronous (at least in 9.3.4). Can you please let me know where you have observed this statement in our documentation? We need to correct this.
I've just extracted a 3,4GB file and the method was correctly blocking as expected until it finished extraction.
Hi @VladimirRosu ,
Thank you for the clarification. I did not see it in a document, but assumed it since I was getting an error with Things["SystemRepository"].MoveFile.
The error I was getting is the following:
************************************************************************************************************
java.lang.Exception: fromFile does not exist [file: /temp/....someFileName]
************************************************************************************************************
It seems that when I fixed an issue related to the fileName located in a code block above the line for MoveFile service, it corrected the "fromFile does not exist" issue,
Things["SystemRepository"].MoveFile({ targetPath: "/Push/" + me.name + "/" + fileName /* STRING */ , overwrite: true /* BOOLEAN */ , sourcePath: "/temp/Push/" + fileName /* STRING */ });
I thought the work around with the do-while loop had fixed the issue, since I added the do-while loop when I fixed the other issue related to the fileName. It's working without the do-while loop now.