From a668818421c3426a64696c37463cc398bd4669db Mon Sep 17 00:00:00 2001 From: Dragory Date: Sun, 18 Feb 2018 20:22:06 +0200 Subject: [PATCH] legacyMigrator: hopefully fix timeout when there are lots of log files to migrate --- src/legacy/legacyMigrator.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/legacy/legacyMigrator.js b/src/legacy/legacyMigrator.js index b4e8f7a..2ccbe33 100644 --- a/src/legacy/legacyMigrator.js +++ b/src/legacy/legacyMigrator.js @@ -94,8 +94,8 @@ async function migrateLogs() { const logDir = config.logDir || `${__dirname}/../../logs`; const logFiles = await readDir(logDir); - const promises = logFiles.map(async logFile => { - if (! logFile.endsWith('.txt')) return; + for (const logFile of logFiles) { + if (! logFile.endsWith('.txt')) continue; const [rawDate, userId, threadId] = logFile.slice(0, -4).split('__'); const date = `${rawDate.slice(0, 10)} ${rawDate.slice(11).replace('-', ':')}`; @@ -113,7 +113,7 @@ async function migrateLogs() { created_at: date }; - return knex.transaction(async trx => { + await knex.transaction(async trx => { const existingThread = await trx('threads') .where('id', newThread.id) .first(); @@ -132,9 +132,7 @@ async function migrateLogs() { created_at: date }); }); - }); - - return Promise.all(promises); + } } async function migrateBlockedUsers() {