Pleroma.Upload.Filter.Dedupe: sharding directory structure

Dedupe now uses a three-level sharding directory structure to improve performance when many files are uploaded and stored on a filesystem instead of an object store. (note: Minio still affected as it still uses a traditional filesystem)

This does not help if you already have hundreds of thousands of files uploaded. The media URLs are permanently part of the activity so the files cannot be relocated. A motivated user could write a tool to move the files and perhaps write an Nginx or equivalent redirect to make the files still accessible, but that is beyond the scope of this change.
This commit is contained in:
Mark Felder 2024-10-29 16:00:18 -04:00
commit d2de251c4d
5 changed files with 21 additions and 8 deletions

View file

@ -174,8 +174,9 @@ defmodule Pleroma.ObjectTest do
filename = Path.basename(href)
assert {:ok, files} = File.ls(uploads_dir)
assert filename in files
expected_path = Path.join([uploads_dir, Pleroma.Upload.Filter.Dedupe.shard_path(filename)])
assert File.exists?(expected_path)
Object.delete(note)
@ -183,8 +184,7 @@ defmodule Pleroma.ObjectTest do
assert Object.get_by_id(note.id).data["deleted"]
assert Object.get_by_id(attachment.id) == nil
assert {:ok, files} = File.ls(uploads_dir)
refute filename in files
refute File.exists?(expected_path)
end
test "with objects that have legacy data.url attribute" do