summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2024-11-12 09:22:44 +0000
committerlain <lain@soykaf.club>2024-11-12 09:22:44 +0000
commitf7bf9a8c8f822b950808e6bf54c9c63923af7466 (patch)
tree7e3ea155e0433bc661746e6266c381027bc1b361 /lib
parent6099a94dbc26c9f86e340769af34c7b28725d831 (diff)
parentebea518c8c9dea17ff18c8fa8192a7957adcfadb (diff)
downloadpleroma-f7bf9a8c8f822b950808e6bf54c9c63923af7466.tar.gz
pleroma-f7bf9a8c8f822b950808e6bf54c9c63923af7466.zip
Merge branch 'dedupe-sharding' into 'develop'
Pleroma.Upload.Filter.Dedupe: sharding directory structure See merge request pleroma/pleroma!4292
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/upload/filter/dedupe.ex10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/pleroma/upload/filter/dedupe.ex b/lib/pleroma/upload/filter/dedupe.ex
index ef793d390..7b278d299 100644
--- a/lib/pleroma/upload/filter/dedupe.ex
+++ b/lib/pleroma/upload/filter/dedupe.ex
@@ -17,8 +17,16 @@ defmodule Pleroma.Upload.Filter.Dedupe do
|> Base.encode16(case: :lower)
filename = shasum <> "." <> extension
- {:ok, :filtered, %Upload{upload | id: shasum, path: filename}}
+
+ {:ok, :filtered, %Upload{upload | id: shasum, path: shard_path(filename)}}
end
def filter(_), do: {:ok, :noop}
+
+ @spec shard_path(String.t()) :: String.t()
+ def shard_path(
+ <<a::binary-size(2), b::binary-size(2), c::binary-size(2), _::binary>> = filename
+ ) do
+ Path.join([a, b, c, filename])
+ end
end