legacyMigrator: hopefully fix timeout when there are lots of log files to migrate

master
Dragory 2018-02-18 20:22:06 +02:00
parent 223c196b95
commit a668818421
1 changed files with 4 additions and 6 deletions

View File

@ -94,8 +94,8 @@ async function migrateLogs() {
const logDir = config.logDir || `${__dirname}/../../logs`; const logDir = config.logDir || `${__dirname}/../../logs`;
const logFiles = await readDir(logDir); const logFiles = await readDir(logDir);
const promises = logFiles.map(async logFile => { for (const logFile of logFiles) {
if (! logFile.endsWith('.txt')) return; if (! logFile.endsWith('.txt')) continue;
const [rawDate, userId, threadId] = logFile.slice(0, -4).split('__'); const [rawDate, userId, threadId] = logFile.slice(0, -4).split('__');
const date = `${rawDate.slice(0, 10)} ${rawDate.slice(11).replace('-', ':')}`; const date = `${rawDate.slice(0, 10)} ${rawDate.slice(11).replace('-', ':')}`;
@ -113,7 +113,7 @@ async function migrateLogs() {
created_at: date created_at: date
}; };
return knex.transaction(async trx => { await knex.transaction(async trx => {
const existingThread = await trx('threads') const existingThread = await trx('threads')
.where('id', newThread.id) .where('id', newThread.id)
.first(); .first();
@ -132,9 +132,7 @@ async function migrateLogs() {
created_at: date created_at: date
}); });
}); });
}); }
return Promise.all(promises);
} }
async function migrateBlockedUsers() { async function migrateBlockedUsers() {