Skip to content

Conversation

@Nothing4You
Copy link
Collaborator

@Nothing4You Nothing4You commented Mar 29, 2025

backports #5565 to 0.19

This commit removes various cases in which Lemmy would purge images from pictrs, which would in many cases not be what admins intended.

pict-rs provides aliases on upload, which allows deduplicating multiple uploads of the same file in the backend, while still providing unique URLs for uploads.

As Lemmy used pictrs' purge API, this meant that not only the image alias referring to removed content was deleted, all other aliases were invalidated as well.

Additionally, even alias deletion would not appropriate in many of these cases, as they were lacking validation that they were exclusively used by the content they were supposed to get removed with.

This implements the following changes:

  1. Purging a community no longer purges the community banner or icon from pict-rs.
  2. Purging a community no longer purges all images referenced in post URLs and post thumbnails within the community from pict-rs.
  3. Banning a user with content removal no longer purges their profile avatar or banner from pict-rs.
  4. Banning a user with content removal no longer purges images referenced in post URLs and post thumbnails for all posts they created from pict-rs.
  5. Banning a user with content removal no longer purges the community banners or icons for all communities they're the top mod of from pict-rs.
  6. Banning a user with content removal now deletes all media they uploaded.
  7. Purging a user no longer purges their profile avatar, banner, or images referenced in post URLs and post thumbnails for all posts they created from pict-rs. All media linked to their user account will still get deleted, which was already explicitly the case in the past.

Some of the mentioned actions will still remove references to image URLs from the database, such as purging a community will still set its icon and banner to NULL in the db, but the associated images will no longer be purged from pict-rs.

As this stops erasure of thumbnails, #5564 has been created to ensure tracking the person that triggered the creation of thumbnails, which will allow removing them like other images.

The only remaining option to purge images attached to a post is now purging an individual post, which still erases the post URL and thumbnail from pict-rs entirely, including any other aliases. Purging and banning users with content removal will remove all aliases associated with them, which will end up deleting those images entirely when there are no other alias remaining.

@Nothing4You Nothing4You force-pushed the pictrs-purges-backport branch 3 times, most recently from 7fa6c77 to 676c57e Compare March 31, 2025 21:34
@Nutomic
Copy link
Member

Nutomic commented Apr 1, 2025

Needs cargo fmt

This commit removes various cases in which Lemmy would purge images from
pictrs, which would in many cases not be what admins intended.

pict-rs provides aliases on upload, which allows deduplicating multiple uploads
of the same file in the backend, while still providing unique URLs for uploads.

As Lemmy used pictrs' purge API, this meant that not only the image alias
referring to removed content was deleted, all other aliases were invalidated as
well.

Additionally, even alias deletion would not appropriate in many of these cases,
as they were lacking validation that they were exclusively used by the content
they were supposed to get removed with.

This implements the following changes:

1. Purging a community no longer purges the community banner or icon from
pict-rs.
2. Purging a community no longer purges all images referenced in post URLs and
post thumbnails within the community from pict-rs.
3. Banning a user with content removal no longer purges their profile avatar or
banner from pict-rs.
4. Banning a user with content removal no longer purges images referenced in
post URLs and post thumbnails for all posts they created from pict-rs.
5. Banning a user with content removal no longer purges the community banners
or icons for all communities they're the top mod of from pict-rs.
6. Banning a user with content removal now deletes all media they uploaded.
7. Purging a user no longer purges their profile avatar, banner, or images
referenced in post URLs and post thumbnails for all posts they created from
pict-rs. All media linked to their user account will still get deleted, which
was already explicitly the case in the past.

Some of the mentioned actions will still remove references to image URLs from
the database, such as purging a community will still set its icon and banner to
`NULL` in the db, but the associated images will no longer be purged from
pict-rs.

As this stops erasure of thumbnails, LemmyNet#5564 has been created to ensure tracking
the person that triggered the creation of thumbnails, which will allow removing
them like other images.

The only remaining option to purge images attached to a post is now purging an
individual post, which still erases the post URL and thumbnail from pict-rs
entirely, including any other aliases. Purging and banning users with content
removal will remove all aliases associated with them, which will end up
deleting those images entirely when there are no other alias remaining.

backports LemmyNet#5565 to 0.19

LemmyNet#5565
LemmyNet@988638d
@Nothing4You Nothing4You force-pushed the pictrs-purges-backport branch from 676c57e to 2fcbb07 Compare April 1, 2025 20:48
@Nothing4You
Copy link
Collaborator Author

rebased, this was also affected by the broken release/v0.19 branch

@Nutomic Nutomic merged commit b01df7a into LemmyNet:release/v0.19 Apr 2, 2025
1 check passed
@Nothing4You Nothing4You deleted the pictrs-purges-backport branch May 30, 2025 00:28
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