Просмотр исходного кода

read zip file stats sequencially

Yuki Takei 5 лет назад
Родитель
Сommit
9b48e991dc
1 измененных файлов с 8 добавлено и 2 удалено
  1. 8 2
      src/server/service/export.js

+ 8 - 2
src/server/service/export.js

@@ -51,10 +51,16 @@ class ExportService {
    */
   async getStatus() {
     const zipFiles = fs.readdirSync(this.baseDir).filter((file) => { return path.extname(file) === '.zip' });
-    const zipFileStats = await Promise.all(zipFiles.map((file) => {
+
+    // sequencial read
+    const zipFileStats = [];
+    const parseZipFilePromises = zipFiles.map((file) => {
       const zipFile = this.getFile(file);
       return this.growiBridgeService.parseZipFile(zipFile);
-    }));
+    });
+    for await (const stat of parseZipFilePromises) {
+      zipFileStats.push(stat);
+    }
 
     // filter null object (broken zip)
     const filtered = zipFileStats.filter(element => element != null);