Removed culled_at flag if a media item gets redownloaded
This commit is contained in:
parent
ea0763b27d
commit
5727a83287
3 changed files with 9 additions and 3 deletions
|
|
@ -79,6 +79,7 @@ defmodule Pinchflat.Downloading.MediaDownloader do
|
||||||
|> MetadataParser.parse_for_media_item()
|
|> MetadataParser.parse_for_media_item()
|
||||||
|> Map.merge(%{
|
|> Map.merge(%{
|
||||||
media_downloaded_at: DateTime.utc_now(),
|
media_downloaded_at: DateTime.utc_now(),
|
||||||
|
culled_at: nil,
|
||||||
nfo_filepath: determine_nfo_filepath(media_with_preloads, parsed_json),
|
nfo_filepath: determine_nfo_filepath(media_with_preloads, parsed_json),
|
||||||
metadata: %{
|
metadata: %{
|
||||||
# IDEA: might be worth kicking off a job for this since thumbnail fetching
|
# IDEA: might be worth kicking off a job for this since thumbnail fetching
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,7 @@ defmodule Pinchflat.Downloading.MediaRetentionWorker do
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|
|
||||||
Logger.info("Deleting #{length(deletable_media)} media items that are from before the source cutoff")
|
Logger.info("Deleting #{length(deletable_media)} media items that are from before the source cutoff")
|
||||||
# TODO: I should ensure that `culled_at` is set to nil if the media item
|
|
||||||
# gets re-downloaded. Because in this case the user could just change the cutoff date and re-download
|
|
||||||
# and I don't think it makes sense to still indicate that the media item was culled.
|
|
||||||
Enum.each(deletable_media, fn media_item ->
|
Enum.each(deletable_media, fn media_item ->
|
||||||
# Note that I'm not setting `prevent_download` on the media_item here.
|
# Note that I'm not setting `prevent_download` on the media_item here.
|
||||||
# That's because cutoff_date can easily change and it's a valid behavior to re-download older
|
# That's because cutoff_date can easily change and it's a valid behavior to re-download older
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ defmodule Pinchflat.Downloading.MediaDownloaderTest do
|
||||||
import Pinchflat.SourcesFixtures
|
import Pinchflat.SourcesFixtures
|
||||||
import Pinchflat.ProfilesFixtures
|
import Pinchflat.ProfilesFixtures
|
||||||
|
|
||||||
|
alias Pinchflat.Media
|
||||||
alias Pinchflat.Downloading.MediaDownloader
|
alias Pinchflat.Downloading.MediaDownloader
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
|
|
@ -123,6 +124,12 @@ defmodule Pinchflat.Downloading.MediaDownloaderTest do
|
||||||
assert DateTime.diff(DateTime.utc_now(), updated_media_item.media_downloaded_at) < 2
|
assert DateTime.diff(DateTime.utc_now(), updated_media_item.media_downloaded_at) < 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it sets the culled_at to nil", %{media_item: media_item} do
|
||||||
|
Media.update_media_item(media_item, %{culled_at: DateTime.utc_now()})
|
||||||
|
assert {:ok, updated_media_item} = MediaDownloader.download_for_media_item(media_item)
|
||||||
|
assert updated_media_item.culled_at == nil
|
||||||
|
end
|
||||||
|
|
||||||
test "it extracts the title", %{media_item: media_item} do
|
test "it extracts the title", %{media_item: media_item} do
|
||||||
assert {:ok, updated_media_item} = MediaDownloader.download_for_media_item(media_item)
|
assert {:ok, updated_media_item} = MediaDownloader.download_for_media_item(media_item)
|
||||||
assert updated_media_item.title == "Pinchflat Example Video"
|
assert updated_media_item.title == "Pinchflat Example Video"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue