From 00ab96e90cbb6ac4edadea5e3006bf7c38ef63ca Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 11 Oct 2018 15:56:18 +0900 Subject: [PATCH] Reduce memory usage in file migration tool --- src/tools/move-drive-files.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/move-drive-files.ts b/src/tools/move-drive-files.ts index 1e6fdcf60..23d1b9497 100644 --- a/src/tools/move-drive-files.ts +++ b/src/tools/move-drive-files.ts @@ -11,8 +11,16 @@ DriveFile.find({ }, { withoutChunks: false }] +}, { + fields: { + _id: true + } }).then(async files => { + console.log(`there is ${files.length} files`); + await sequential(files.map(file => async () => { + file = await DriveFile.findOne({ _id: file._id }); + const minio = new Minio.Client(config.drive.config); const keyDir = `${config.drive.prefix}/${uuid.v4()}`;