[Enhancement] Allow redownloading of files for existing media items (#239)

* Added ability to specify overwrite behaviour when downloading media

* Added helper for redownloading media items

* renamed media redownload worker to disambiguate it from similarly named methods

* Added new redownload option to source actions dropdown

* Refactored MediaQuery to use a __using__ macro

* docs
This commit is contained in:
Kieran
2024-05-13 14:25:39 -07:00
committed by GitHub
parent 5c86e7192e
commit a38ffbc55b
27 changed files with 247 additions and 71 deletions
@@ -104,7 +104,7 @@ defmodule PinchflatWeb.Sources.SourceController do
|> redirect(to: ~p"/sources")
end
def force_download(conn, %{"source_id" => id}) do
def force_download_pending(conn, %{"source_id" => id}) do
wrap_forced_action(
conn,
id,
@@ -113,6 +113,15 @@ defmodule PinchflatWeb.Sources.SourceController do
)
end
def force_redownload(conn, %{"source_id" => id}) do
wrap_forced_action(
conn,
id,
"Forcing re-download of downloaded media items.",
&DownloadingHelpers.kickoff_redownload_for_existing_media/1
)
end
def force_index(conn, %{"source_id" => id}) do
wrap_forced_action(
conn,
@@ -31,11 +31,20 @@
</:option>
<:option :if={@source.download_media}>
<.link
href={~p"/sources/#{@source}/force_download"}
href={~p"/sources/#{@source}/force_download_pending"}
method="post"
data-confirm="Are you sure you want to force a download of all *pending* media items? This isn't normally needed."
>
Force Download
Download Pending
</.link>
</:option>
<:option :if={@source.download_media}>
<.link
href={~p"/sources/#{@source}/force_redownload"}
method="post"
data-confirm="Are you sure you want to re-download all currently downloaded media items? This isn't normally needed and won't change anything if the files already exist."
>
Redownload Existing
</.link>
</:option>
<:option>
@@ -1,10 +1,9 @@
defmodule Pinchflat.Sources.MediaItemTableLive do
use PinchflatWeb, :live_view
import Ecto.Query, warn: false
use Pinchflat.Media.MediaQuery
alias Pinchflat.Repo
alias Pinchflat.Sources
alias Pinchflat.Media.MediaQuery
alias Pinchflat.Utils.NumberUtils
@limit 10