This commit is contained in:
Karol Wypchlo 2021-09-29 19:27:18 +02:00
parent a6f428db82
commit f8b8e1e437
No known key found for this signature in database
GPG Key ID: C92C016317A964D0
1 changed files with 3 additions and 3 deletions

View File

@ -62,15 +62,15 @@ async function handleGetLink(
const record = await recordsDB.findOne({ cid }); const record = await recordsDB.findOne({ cid });
console.log(record);
if (record && record.skylink) { if (record && record.skylink) {
res.status(200).send({ skylink: record.skylink }); res.status(200).send({ skylink: record.skylink });
return; return;
} }
// insert an empty record for the cid // insert an empty record for the cid
await recordsDB.insertOne({ cid, createdAt: new Date(), skylink: "" }); if (!record) {
await recordsDB.insertOne({ cid, createdAt: new Date(), skylink: "" });
}
// reupload the cid and return the skylink // reupload the cid and return the skylink
const skylink = await reuploadFile(cid, recordsDB); const skylink = await reuploadFile(cid, recordsDB);