Skip to content

Add a Blossom option to delete blobs when their events are deleted#35

Open
dtonon wants to merge 2 commits into
fiatjaf:masterfrom
dtonon:blobs-deletion-by-admins
Open

Add a Blossom option to delete blobs when their events are deleted#35
dtonon wants to merge 2 commits into
fiatjaf:masterfrom
dtonon:blobs-deletion-by-admins

Conversation

@dtonon

@dtonon dtonon commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Another feature from my dev fork of Pyramid to experiment with Squalk.
The idea is to introduce an automatism to keep the blossom storage as clean as possible, and to let an admin to moderate efficiently a message without leaving media around.

Comment thread blossom/reclaim.go
}

// match blob urls that point to this server: <domain>/<sha256>
re := regexp.MustCompile(regexp.QuoteMeta(domain) + `/([0-9a-f]{64})`)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should match every URL, not only those pointed to this server, because blossom objects are naturally hosted in multiple places and the primary URL in the event may not be this server.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I can't delete other people's files on a server that doesn't belong to me, right?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is:

  • Bob uses two blossom servers, M and N. He uploads blob Z to both.
  • Then Bob's client creates the URL in the post pointing to N/z, he publishes the post to his relays, M and O (M is this pyramid instance that acts as both a blossom server and a relay).
  • Now Bob deletes his note from M (the relay).
  • While cleaning up blobs related to Bob's note that has just been deleted, we need M to find blob Z even though the URL in the note is N/z.

@fiatjaf

fiatjaf commented Jul 1, 2026

Copy link
Copy Markdown
Owner

I thought about doing this, but the problem is that the same blob may be referenced by multiple events, even from the same author, so it becomes a much harder problem.

@fiatjaf

fiatjaf commented Jul 1, 2026

Copy link
Copy Markdown
Owner

I think it makes more sense probably to add a "garbage collect" button that scans all events from an author for blobs, then delete those blobs that aren't referenced by any.

On the other hand, this breaks everything if people are storing things that are only referenced elsewhere.

Turns out blossom is a bit of a big mess.

@dtonon

dtonon commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

the problem is that the same blob may be referenced by multiple events

Damn I hadn't thought of that. It seems like an extreme case, but when you think about it, it's not really that extreme, also because if the same user uploads the same file again, they might expect it to be saved as a duplicate, and so be immune to the deletion of another post.

@dtonon

dtonon commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

A check has been added to prevent a blob from being deleted if it is referenced by other events.
Of course this doesn't protect the blob if it's referenced elsewhere.

@fiatjaf

fiatjaf commented Jul 1, 2026

Copy link
Copy Markdown
Owner

I guess this fixes it, but it feels too inefficient to run through all the events of this person just to check if any references a blob.

Specially because some clients will flood relays with deletions, that might have blobs in them, notably replaceable events (which act like deletions).

But maybe it will be ok. I'll think about it a little more.

@dtonon

dtonon commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

An option is to limit the linked deletion to admins. This is actually the use case I started from (remove entirely spam and sensitive content).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants