From 74e7d27ba4e25fae380a73815eb95d448caa54d4 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 16 Sep 2024 14:46:16 +0100 Subject: [PATCH] Run the image import sequentially Changed this for debug as many images are huge and were tripping the logic off - the whole importer logic needs to be restructured for better parallelism. --- lib/music_library/records/importer.ex | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/music_library/records/importer.ex b/lib/music_library/records/importer.ex index b0cdf6e4..4b02718d 100644 --- a/lib/music_library/records/importer.ex +++ b/lib/music_library/records/importer.ex @@ -73,16 +73,12 @@ defmodule MusicLibrary.Records.Importer do def import_all_cover_images do Rec |> MusicLibrary.Repo.all() - |> Task.async_stream( - fn r -> - if r.image_data == nil do - import_cover_image(r) - IO.puts("Imported cover image for #{r.title}") - end - end, - timeout: 10_000 - ) - |> Stream.run() + |> Enum.each(fn r -> + if r.image_data == nil do + import_cover_image(r) + IO.puts("Imported cover image for #{r.title}") + end + end) end def import_all do