mirror of
https://github.com/kieraneglin/pinchflat.git
synced 2026-01-23 02:24:24 +00:00
Ensured first indexing pass runs if a source has never been indexed before (#581)
This commit is contained in:
parent
993c57f853
commit
3dd20141e0
2 changed files with 21 additions and 3 deletions
|
|
@ -231,8 +231,9 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpers do
|
|||
# The download archive isn't useful for playlists (since those are ordered arbitrarily)
|
||||
# and we don't want to use it if the indexing was forced by the user. In other words,
|
||||
# only create an archive for channels that are being indexed as part of their regular
|
||||
# indexing schedule
|
||||
# indexing schedule. The first indexing pass should also not create an archive.
|
||||
defp build_download_archive_options(%Source{collection_type: :playlist}, _was_forced), do: []
|
||||
defp build_download_archive_options(%Source{last_indexed_at: nil}, _was_forced), do: []
|
||||
defp build_download_archive_options(_source, true), do: []
|
||||
|
||||
defp build_download_archive_options(source, _was_forced) do
|
||||
|
|
|
|||
|
|
@ -475,7 +475,9 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do
|
|||
end
|
||||
|
||||
describe "index_and_enqueue_download_for_media_items when testing the download archive" do
|
||||
test "a download archive is used if the source is a channel", %{source: source} do
|
||||
test "a download archive is used if the source is a channel that has been indexed before" do
|
||||
source = source_fixture(%{collection_type: :channel, last_indexed_at: now()})
|
||||
|
||||
expect(YtDlpRunnerMock, :run, fn _url, :get_media_attributes_for_collection, opts, _ot, _addl_opts ->
|
||||
assert :break_on_existing in opts
|
||||
assert Keyword.has_key?(opts, :download_archive)
|
||||
|
|
@ -499,6 +501,19 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do
|
|||
SlowIndexingHelpers.index_and_enqueue_download_for_media_items(source)
|
||||
end
|
||||
|
||||
test "a download archive is not used if the source has never been indexed before" do
|
||||
source = source_fixture(%{collection_type: :channel, last_indexed_at: nil})
|
||||
|
||||
expect(YtDlpRunnerMock, :run, fn _url, :get_media_attributes_for_collection, opts, _ot, _addl_opts ->
|
||||
refute :break_on_existing in opts
|
||||
refute Keyword.has_key?(opts, :download_archive)
|
||||
|
||||
{:ok, source_attributes_return_fixture()}
|
||||
end)
|
||||
|
||||
SlowIndexingHelpers.index_and_enqueue_download_for_media_items(source)
|
||||
end
|
||||
|
||||
test "a download archive is not used if the index has been forced to run" do
|
||||
source = source_fixture(%{collection_type: :channel})
|
||||
|
||||
|
|
@ -512,7 +527,9 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do
|
|||
SlowIndexingHelpers.index_and_enqueue_download_for_media_items(source, was_forced: true)
|
||||
end
|
||||
|
||||
test "the download archive is formatted correctly and contains the right video", %{source: source} do
|
||||
test "the download archive is formatted correctly and contains the right video" do
|
||||
source = source_fixture(%{collection_type: :channel, last_indexed_at: now()})
|
||||
|
||||
media_items =
|
||||
1..21
|
||||
|> Enum.map(fn n ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue