fix(core): update

This commit is contained in:
2021-12-20 15:11:21 +01:00
parent b32c06aef2
commit b391e54083
4 changed files with 22 additions and 8 deletions

View File

@ -377,11 +377,22 @@ export const listFileTree = async (
/**
* checks wether a file is ready for processing
*/
export const waitForFileToBeReady = async (filePathArg: string) => {
const limitedArray = new plugins.lik.LimitedArray<string>(3);
if(!plugins.path.isAbsolute(filePathArg)) {
export const waitForFileToBeReady = async (filePathArg: string): Promise<void> => {
if (!plugins.path.isAbsolute(filePathArg)) {
filePathArg = plugins.path.resolve(filePathArg);
};
const stats = await plugins.fsExtra.stat(filePathArg);
stats.size
}
}
const limitedArray = new plugins.lik.LimitedArray<number>(3);
let fileReady = false;
while (!fileReady) {
const stats = await plugins.fsExtra.stat(filePathArg);
limitedArray.addOne(stats.size);
if (
limitedArray.array.length < 3 ||
!(limitedArray.array[0] === limitedArray[1] && limitedArray.array[1] === limitedArray[2])
) {
await plugins.smartdelay.delayFor(5000);
} else {
fileReady = true;
}
}
};