update db file with lastUpdated
This commit is contained in:
parent
4abf2ef021
commit
04d110d8fe
1 changed files with 14 additions and 1 deletions
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue