Fix to blob deletion w/ disk store ()

pds: ensure account deletion doesn't touch others' blobs
This commit is contained in:
devin ivy 2024-04-03 16:54:41 -04:00 committed by GitHub
parent 97482da17a
commit 9b78f06134
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 2 deletions
packages

@ -76,7 +76,10 @@ export class SeedClient<
{ text: string; ref: RecordRef; images: ImageRef[]; quote?: RecordRef }[]
>
likes: Record<string, Record<string, AtUri>>
replies: Record<string, { text: string; ref: RecordRef }[]>
replies: Record<
string,
{ text: string; ref: RecordRef; images: ImageRef[] }[]
>
reposts: Record<string, RecordRef[]>
lists: Record<
string,
@ -378,6 +381,7 @@ export class SeedClient<
const reply = {
text,
ref: new RecordRef(res.uri, res.cid),
images: images ?? [],
}
this.replies[by].push(reply)
return reply

@ -141,7 +141,9 @@ export class DiskBlobStore implements BlobStore {
}
async deleteAll(): Promise<void> {
await rmIfExists(this.location, true)
await rmIfExists(path.join(this.location, this.did), true)
await rmIfExists(path.join(this.tmpLocation, this.did), true)
await rmIfExists(path.join(this.quarantineLocation, this.did), true)
}
}

@ -185,6 +185,13 @@ describe('account deletion', () => {
await expect(attempt2).rejects.toThrow(BlobNotFoundError)
})
it('maintains blobs from other actors', async () => {
const bobBlobstore = network.pds.ctx.blobstore(sc.dids.bob)
const [img] = sc.replies[sc.dids.bob][0].images
const attempt = bobBlobstore.getBytes(img.image.ref)
await expect(attempt).resolves.toBeDefined()
})
it('can delete an empty user', async () => {
const eve = await sc.createAccount('eve', {
handle: 'eve.test',