mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27: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
|
end
|
||||||
|
|
||||||
defp bulk_rename(file_names, source_prefix, target_prefix) do
|
defp bulk_rename(file_names, source_prefix, target_prefix) do
|
||||||
Enum.map(file_names, fn name ->
|
file_names
|
||||||
source = Path.join(source_prefix, name)
|
|> Task.async_stream(
|
||||||
target = Path.join(target_prefix, name)
|
fn name ->
|
||||||
|
source = Path.join(source_prefix, name)
|
||||||
|
target = Path.join(target_prefix, name)
|
||||||
|
Objects.copy(source, target)
|
||||||
|
|
||||||
Objects.copy(source, target)
|
name
|
||||||
Objects.delete(source)
|
end,
|
||||||
end)
|
timeout: :infinity
|
||||||
|
)
|
||||||
|
|> Stream.map(fn {:ok, name} -> name end)
|
||||||
|
|> bulk_delete(source_prefix)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp bulk_delete(file_names, prefix) do
|
defp bulk_delete(file_names, prefix) do
|
||||||
|
|
Loading…
Reference in a new issue