diff --git a/README.md b/README.md index 14264a5..6f8a3b0 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,10 @@ TODO: - [x] Backfill network - [x] Store did+route -> blob & mime type in database - [x] Store blobs for CDN (max ~0.25gb per user) -- [ ] Moderate illegal content or hope that people are niceys +- [x] Moderate illegal content or hope that people are niceys + (Hope that people are niceys) - [ ] Finish CLI tool - [ ] Sign in via app password - - [ ] Sign in via oAuth (for interactive) - [ ] Clear old site - [ ] Upload new site - [ ] Fuse uploader diff --git a/server/src/backfill/blob.ts b/server/src/backfill/blob.ts index 16cb7ba..4e28d40 100644 --- a/server/src/backfill/blob.ts +++ b/server/src/backfill/blob.ts @@ -5,6 +5,11 @@ export default async function ( did: `did:${"plc" | "web"}:${string}`, cid: string ): Promise { + // if the user has been manually taken down (cache dir deleted and replaced with empty file) + // this errors out for quick exit + // saving the round trip to resolve the pds and blob. + await Deno.mkdir(`./blobs/${did}`, { recursive: true }); + const pds = await getPds(did); if (!pds) throw "PDS not found"; @@ -20,18 +25,20 @@ export default async function ( if (!ok) throw `${data.error}`; - // check for CSAM etc here - - await Deno.mkdir(`./blobs/${did}`, { recursive: true }); - let size = 0; - for await (const file of Deno.readDir(`./blobs/${did}`)) { - size += (await Deno.stat(`./blobs/${did}/${file.name}`)).size; + // if the file size cant be calculated or the file cant be written, still return the blob + try { + let size = 0; + for await (const file of Deno.readDir(`./blobs/${did}`)) { + size += (await Deno.stat(`./blobs/${did}/${file.name}`)).size; + } + // only write if total stays below max site size + if (size + data.size <= MAX_SITE_SIZE) + await Deno.writeFile(`./blobs/${did}/${cid}`, await data.bytes(), { + createNew: true, + }); + } catch (e) { + console.warn(e); } - // only write if total stays below max site size - if (size + data.size <= MAX_SITE_SIZE) - await Deno.writeFile(`./blobs/${did}/${cid}`, await data.bytes(), { - createNew: true, - }); return data; } diff --git a/server/src/routes/user.ts b/server/src/routes/user.ts index 1c2a3d5..d21b3c2 100644 --- a/server/src/routes/user.ts +++ b/server/src/routes/user.ts @@ -106,7 +106,10 @@ ${db_res.did} is not a valid DID. This account could not be resolved console.error(e); return new Response(`${ascii} -This page couldn't be resolved. Either the blob does not exist, or contained illegal content. +This page could not be resolved. Either: +- The user has no PDS +- The blob does not exist +- The user has been manually hidden for uploading illegal content. `); } }