diff --git a/run-downloadDb.js b/run-downloadDb.js index f4b9e48..9686f60 100644 --- a/run-downloadDb.js +++ b/run-downloadDb.js @@ -1,4 +1,4 @@ -import { readFile } from 'fs/promises'; +import { readFile, writeFile } from 'fs/promises'; import { getArg } from './lib/args.js'; import { getMany } from './lib/dl.js'; @@ -36,6 +36,7 @@ const downloadDb = async () => { let processes = db.map(entry => ({ ...entry, + lastUpdated: Date.now(), logs: [], })); @@ -54,6 +55,18 @@ const downloadDb = async () => { } }); }); + + log(ctx, 'Updating the db'); + try { + let updated = processes.map(entry => ({ + user: entry.user, + lastUpdated: entry.lastUpdated, + })); + await writeFile(`${directory}/db.json`, JSON.stringify(updated, null, 2)); + } catch (err) { + error(ctx, err); + return; + } log(ctx, 'Done'); }