feat(readarr): refresh and rescan a Readarr author and expose the command on the CLI

Posts the RefreshAuthor command to the command endpoint with the author ID, queueing a metadata refresh and a disk scan for that author. The response is returned verbatim and no app state is mutated.

Adds the refresh subcommand group to the Readarr CLI.
This commit is contained in:
Dark-Alex-17 committed 2026-08-27 10:43:37 -06:00
1 parent e9b9aa3a14
commit c82006862e
7 files changed
+258 -1

No files matched your search

@@ -361,4 +361,25 @@ impl Network<'_, '_> {
.handle_request::<ReadarrCommandBody, Value>(request_props, |_, _| ())
.await
}
pub(in crate::network::readarr_network) async fn update_and_scan_author(
&mut self,
author_id: i64,
) -> Result<Value> {
let event = ReadarrEvent::UpdateAndScanAuthor(author_id);
info!("Updating and scanning author with ID: {author_id}");
let body = ReadarrCommandBody {
name: "RefreshAuthor".to_owned(),
author_id: Some(author_id),
..ReadarrCommandBody::default()
};
let request_props = self
.request_props_from(event, RequestMethod::Post, Some(body), None, None)
.await;
self
.handle_request::<ReadarrCommandBody, Value>(request_props, |_, _| ())
.await
}
}
@@ -800,4 +800,47 @@ mod tests {
mock.assert_async().await;
assert_err!(result);
}
#[tokio::test]
async fn test_handle_update_and_scan_author_event() {
let (mock, app, _server) = MockServarrApi::post()
.with_request_body(json!({
"name": "RefreshAuthor",
"authorId": 1
}))
.returns(json!({}))
.build_for(ReadarrEvent::UpdateAndScanAuthor(1))
.await;
app.lock().await.server_tabs.set_index(3);
let mut network = test_network(&app);
let result = network
.handle_readarr_event(ReadarrEvent::UpdateAndScanAuthor(1))
.await;
mock.assert_async().await;
assert_ok!(result);
}
#[tokio::test]
async fn test_handle_update_and_scan_author_event_failure() {
let (mock, app, _server) = MockServarrApi::post()
.with_request_body(json!({
"name": "RefreshAuthor",
"authorId": 1
}))
.returns(json!({"name": "RefreshAuthor", "status": "queued"}))
.status(500)
.build_for(ReadarrEvent::UpdateAndScanAuthor(1))
.await;
app.lock().await.server_tabs.set_index(3);
let mut network = test_network(&app);
let result = network
.handle_readarr_event(ReadarrEvent::UpdateAndScanAuthor(1))
.await;
mock.assert_async().await;
assert_err!(result);
}
}
+7 -1
View File
@@ -50,6 +50,7 @@ pub enum ReadarrEvent {
StartTask(ReadarrTaskName),
ToggleAuthorMonitoring(i64),
TriggerAutomaticAuthorSearch(i64),
UpdateAndScanAuthor(i64),
}
impl NetworkResource for ReadarrEvent {
@@ -64,7 +65,8 @@ impl NetworkResource for ReadarrEvent {
ReadarrEvent::SearchNewAuthor(_) => "/author/lookup",
ReadarrEvent::GetQueuedEvents
| ReadarrEvent::StartTask(_)
| ReadarrEvent::TriggerAutomaticAuthorSearch(_) => "/command",
| ReadarrEvent::TriggerAutomaticAuthorSearch(_)
| ReadarrEvent::UpdateAndScanAuthor(_) => "/command",
ReadarrEvent::GetHostConfig | ReadarrEvent::GetSecurityConfig => "/config/host",
ReadarrEvent::GetDiskSpace => "/diskspace",
ReadarrEvent::HealthCheck => "/health",
@@ -176,6 +178,10 @@ impl Network<'_, '_> {
.trigger_automatic_author_search(author_id)
.await
.map(ReadarrSerdeable::from),
ReadarrEvent::UpdateAndScanAuthor(author_id) => self
.update_and_scan_author(author_id)
.await
.map(ReadarrSerdeable::from),
}
}
@@ -25,6 +25,7 @@ mod tests {
#[case(ReadarrEvent::GetQueuedEvents, "/command")]
#[case(ReadarrEvent::StartTask(Default::default()), "/command")]
#[case(ReadarrEvent::TriggerAutomaticAuthorSearch(1), "/command")]
#[case(ReadarrEvent::UpdateAndScanAuthor(1), "/command")]
#[case(ReadarrEvent::GetHostConfig, "/config/host")]
#[case(ReadarrEvent::GetSecurityConfig, "/config/host")]
#[case(ReadarrEvent::GetDiskSpace, "/diskspace")]