diff --git a/lib/pinchflat/downloading/media_download_worker.ex b/lib/pinchflat/downloading/media_download_worker.ex index dcd58c9..17ab5b5 100644 --- a/lib/pinchflat/downloading/media_download_worker.ex +++ b/lib/pinchflat/downloading/media_download_worker.ex @@ -40,8 +40,8 @@ defmodule Pinchflat.Downloading.MediaDownloadWorker do |> Media.get_media_item!() |> Repo.preload(:source) - # If the source is set to not download media, perform a no-op - if media_item.source.download_media || args["force"] do + # If the source or media item is set to not download media, perform a no-op unless forced + if (media_item.source.download_media && !media_item.prevent_download) || args["force"] do download_media_and_schedule_jobs(media_item) else :ok diff --git a/test/pinchflat/downloading/media_download_worker_test.exs b/test/pinchflat/downloading/media_download_worker_test.exs index 3500a8a..b227c31 100644 --- a/test/pinchflat/downloading/media_download_worker_test.exs +++ b/test/pinchflat/downloading/media_download_worker_test.exs @@ -4,6 +4,7 @@ defmodule Pinchflat.Downloading.MediaDownloadWorkerTest do import Mox import Pinchflat.MediaFixtures + alias Pinchflat.Media alias Pinchflat.Sources alias Pinchflat.Filesystem.FilesystemHelpers alias Pinchflat.Downloading.MediaDownloadWorker @@ -117,10 +118,19 @@ defmodule Pinchflat.Downloading.MediaDownloadWorkerTest do perform_job(MediaDownloadWorker, %{id: media_item.id}) end + test "does not download if the media item is set to not download", %{media_item: media_item} do + expect(YtDlpRunnerMock, :run, 0, fn _url, _opts, _ot, _addl -> :ok end) + + Media.update_media_item(media_item, %{prevent_download: true}) + + perform_job(MediaDownloadWorker, %{id: media_item.id}) + end + test "downloads anyway if forced", %{media_item: media_item} do expect(YtDlpRunnerMock, :run, fn _url, _opts, _ot, _addl -> :ok end) Sources.update_source(media_item.source, %{download_media: false}) + Media.update_media_item(media_item, %{prevent_download: true}) perform_job(MediaDownloadWorker, %{id: media_item.id, force: true}) end