From 389f420cad02a3d934d92bcf1f93cea91432404a Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 9 Oct 2018 05:46:21 +0900 Subject: [PATCH] Update src/tools/move-drive-files.ts --- src/tools/move-drive-files.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tools/move-drive-files.ts b/src/tools/move-drive-files.ts index e34652243..1e6fdcf60 100644 --- a/src/tools/move-drive-files.ts +++ b/src/tools/move-drive-files.ts @@ -1,5 +1,6 @@ import * as Minio from 'minio'; import * as uuid from 'uuid'; +const sequential = require('promise-sequential'); import DriveFile, { DriveFileChunk, getDriveFileBucket } from '../models/drive-file'; import DriveFileThumbnail, { DriveFileThumbnailChunk } from '../models/drive-file-thumbnail'; import config from '../config'; @@ -11,7 +12,7 @@ DriveFile.find({ withoutChunks: false }] }).then(async files => { - files.forEach(async file => { + await sequential(files.map(file => async () => { const minio = new Minio.Client(config.drive.config); const keyDir = `${config.drive.prefix}/${uuid.v4()}`; @@ -60,5 +61,7 @@ DriveFile.find({ await DriveFileThumbnail.remove({ _id: thumbnail._id }); } //#endregion - }); + + console.log('done', file._id); + })); });