Browse Source

fix: asynchronous file write for at import job

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5031/head
mertmit 2 years ago
parent
commit
477943e237
  1. 13
      packages/nocodb/src/lib/meta/api/sync/helpers/job.ts

13
packages/nocodb/src/lib/meta/api/sync/helpers/job.ts

@ -8,6 +8,7 @@ import { Api } from 'nocodb-sdk';
import Airtable from 'airtable';
import jsonfile from 'jsonfile';
import hash from 'object-hash';
import { promisify } from 'util';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
@ -16,6 +17,8 @@ import { importData, importLTARData } from './readAndProcessData';
import EntityMap from './EntityMap';
const writeJsonFileAsync = promisify(jsonfile.writeFile);
dayjs.extend(utc);
const selectColors = {
@ -204,7 +207,7 @@ export default async (
// store copy of airtable schema globally
g_aTblSchema = file.tableSchemas;
if (debugMode) jsonfile.writeFileSync('aTblSchema.json', ft, { spaces: 2 });
if (debugMode) await writeJsonFileAsync('aTblSchema.json', ft, { spaces: 2 });
return file;
}
@ -216,7 +219,7 @@ export default async (
rtc.fetchAt.count++;
rtc.fetchAt.time += duration;
if (debugMode) jsonfile.writeFileSync(`${viewId}.json`, ft, { spaces: 2 });
if (debugMode) await writeJsonFileAsync(`${viewId}.json`, ft, { spaces: 2 });
return ft.view;
}
@ -1917,13 +1920,13 @@ export default async (
logBasic(`:: Axios fetch time: ${rtc.fetchAt.time}`);
if (debugMode) {
jsonfile.writeFileSync('stats.json', perfStats, { spaces: 2 });
await writeJsonFileAsync('stats.json', perfStats, { spaces: 2 });
const perflog = [];
for (let i = 0; i < perfStats.length; i++) {
perflog.push(`${perfStats[i].e}, ${perfStats[i].d}`);
}
jsonfile.writeFileSync('stats.csv', perflog, { spaces: 2 });
jsonfile.writeFileSync('skip.txt', rtc.migrationSkipLog.log, {
await writeJsonFileAsync('stats.csv', perflog, { spaces: 2 });
await writeJsonFileAsync('skip.txt', rtc.migrationSkipLog.log, {
spaces: 2,
});
}

Loading…
Cancel
Save