for await()

in util/upload/src/upload.ts [98:130]


    for await (const file of glob.scan({onlyFiles: true})) {

        // remove path from folder and prepend the result to entry
        let fileAddr = file.substring(path.length + 1);
        if (fileAddr.startsWith("/")) {
            fileAddr = fileAddr.substring(1);
        }

        const promise: Promise<Result> = (async () => {
            counter.files++;

            // upload command
            const fileItem = Bun.file(file);
            if (fileItem.size > 0) {
                return await minioUtils.uploadContent(file, fileAddr);
            } else {
                console.log(`Skipped empty file ${file}`);
                return await new Promise((resolve) => {
                    resolve(Result.SKIPPED);
                });
            }

        })();

        promiseBatch.push(promise);

        // If the batch size reaches batchSize, wait for them to resolve
        if (promiseBatch.length === batchSize) {
            const results = await Promise.all<Result>(promiseBatch);
            parseResults(results, counter);
            promiseBatch = []; // clear the batch
        }
    }