update post job

This commit is contained in:
cutestnekoaqua 2023-03-29 19:36:23 +02:00
parent 220b022461
commit 82f342cf45
No known key found for this signature in database
GPG Key ID: 6BF0964A5069C1E0
1 changed files with 6 additions and 3 deletions

View File

@ -31,12 +31,12 @@ export async function importPosts(
return; return;
} }
const csv = await downloadTextFile(file.url); const json = await downloadTextFile(file.url);
let linenum = 0; let linenum = 0;
if (file.type.endsWith("json")) { try {
for (const post of JSON.parse(csv)) { for (const post of JSON.parse(json)) {
try { try {
if (post.replyId != null) { if (post.replyId != null) {
logger.info(`Is reply, skip [${linenum}] ...`); logger.info(`Is reply, skip [${linenum}] ...`);
@ -74,6 +74,9 @@ export async function importPosts(
logger.warn(`Error in line:${linenum} ${e}`); logger.warn(`Error in line:${linenum} ${e}`);
} }
} }
} catch (e) {
// handle error
logger.warn(`Error reading: ${e}`);
} }
logger.succ("Imported"); logger.succ("Imported");