mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 14:17:59 +01:00
Improve performance of bulk renames
This commit is contained in:
parent
b9ab699b01
commit
244ea56d0f
1 changed files with 12 additions and 6 deletions
|
@ -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 ->
|
||||
source = Path.join(source_prefix, name)
|
||||
target = Path.join(target_prefix, 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.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
|
||||
|
|
Loading…
Reference in a new issue