Improve performance of bulk renames

This commit is contained in:
byte[] 2022-05-18 22:45:32 -04:00
parent b9ab699b01
commit 244ea56d0f

View file

@ -134,13 +134,19 @@ defmodule Philomena.Images.Thumbnailer do
end
defp bulk_rename(file_names, source_prefix, target_prefix) do
Enum.map(file_names, fn name ->
file_names
|> Task.async_stream(
fn name ->
source = Path.join(source_prefix, name)
target = Path.join(target_prefix, name)
Objects.copy(source, target)
Objects.delete(source)
end)
name
end,
timeout: :infinity
)
|> Stream.map(fn {:ok, name} -> name end)
|> bulk_delete(source_prefix)
end
defp bulk_delete(file_names, prefix) do