From 06e4855d9bc6ca0220fb87f822a0d40700a07a3b Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Thu, 26 Sep 2024 12:08:41 -0700 Subject: [PATCH] Added placeholder action to source page --- .../controllers/sources/source_controller.ex | 11 +++++++++++ .../sources/source_html/actions_dropdown.html.heex | 13 +++++++++++-- lib/pinchflat_web/router.ex | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/pinchflat_web/controllers/sources/source_controller.ex b/lib/pinchflat_web/controllers/sources/source_controller.ex index 1573762..26d47f7 100644 --- a/lib/pinchflat_web/controllers/sources/source_controller.ex +++ b/lib/pinchflat_web/controllers/sources/source_controller.ex @@ -175,6 +175,17 @@ defmodule PinchflatWeb.Sources.SourceController do ) end + # TODO: test + # TODO: update the job that's running + def sync_files_on_disk(conn, %{"source_id" => id}) do + wrap_forced_action( + conn, + id, + "File sync enqueued.", + &SourceMetadataStorageWorker.kickoff_with_task/1 + ) + end + defp wrap_forced_action(conn, source_id, message, fun) do source = Sources.get_source!(source_id) fun.(source) diff --git a/lib/pinchflat_web/controllers/sources/source_html/actions_dropdown.html.heex b/lib/pinchflat_web/controllers/sources/source_html/actions_dropdown.html.heex index 43b4c22..0495384 100644 --- a/lib/pinchflat_web/controllers/sources/source_html/actions_dropdown.html.heex +++ b/lib/pinchflat_web/controllers/sources/source_html/actions_dropdown.html.heex @@ -38,7 +38,7 @@ <.link 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." + data-confirm="Are you sure you want to force a download of all pending media items? This isn't normally needed." > Download Pending @@ -47,7 +47,7 @@ <.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." + data-confirm="Are you sure you want to re-download all currently downloaded media items? This doesn't upgrade your media, but will download any missing files if your settings have changed. This isn't normally needed." > Redownload Existing @@ -70,6 +70,15 @@ Refresh Metadata + <:option> + <.link + href={~p"/sources/#{@source}/sync_files_on_disk"} + method="post" + data-confirm="Are you sure you want to sync files? This will update media items if their files have been deleted. File addition or moves are not detected. This isn't normally needed." + > + Sync Files on Disk + + <:option>
diff --git a/lib/pinchflat_web/router.ex b/lib/pinchflat_web/router.ex index 1e1ee7d..9ba7068 100644 --- a/lib/pinchflat_web/router.ex +++ b/lib/pinchflat_web/router.ex @@ -40,6 +40,7 @@ defmodule PinchflatWeb.Router do post "/force_redownload", Sources.SourceController, :force_redownload post "/force_index", Sources.SourceController, :force_index post "/force_metadata_refresh", Sources.SourceController, :force_metadata_refresh + post "/sync_files_on_disk", Sources.SourceController, :sync_files_on_disk resources "/media", MediaItems.MediaItemController, only: [:show, :edit, :update, :delete] do post "/force_download", MediaItems.MediaItemController, :force_download