Compare commits

...
2 Commits
Author SHA1 Message Date
Dark-Alex-17 21749a62ea fix: config-path correctly displays the config file used even if --config-file is passed
Check / stable / fmt (push) Failing after 27s
Check / beta / clippy (push) Failing after 1m11s
Check / stable / clippy (push) Failing after 1m11s
Check / nightly / doc (push) Successful in 1m1s
Check / 1.95.0 / check (push) Successful in 1m8s
Check / dockerfile / msrv (push) Successful in 5s
Test Suite / ubuntu / beta (push) Successful in 2m17s
Test Suite / ubuntu / stable (push) Successful in 2m16s
Test Suite / ubuntu / stable / coverage (push) Failing after 1m57s
Test Suite / macos-latest / stable (push) Canceled after 0s
Test Suite / windows-latest / stable (push) Canceled after 0s
2026-10-14 12:56:31 -06:00
Dark-Alex-17 947b3c2eda fix: only instantiate the reqwest client on paths that actually need it 2026-10-14 12:49:23 -06:00
3 changed files with 60 additions and 4 deletions

No files matched your search

+2 -2
View File
@@ -51,8 +51,8 @@ pub enum Command {
},
#[command(about = indoc!{"
Print the full path to the default configuration file.
This file can be changed to another location using the '--config-file' flag
Print the full path to the configuration file in use.
This is the default configuration file location unless overridden with the '--config-file' flag
"})]
ConfigPath,
}
+6 -2
View File
@@ -131,7 +131,10 @@ async fn main() -> Result<()> {
let default_config_path = config_file_path.display().to_string();
if matches!(args.command, Some(Command::ConfigPath)) {
println!("{default_config_path}");
match args.global.config_file {
Some(ref config_file) => println!("{}", config_file.display()),
None => println!("{default_config_path}"),
}
return Ok(());
}
@@ -153,7 +156,6 @@ async fn main() -> Result<()> {
config.validate(&config_path);
config.post_process_initialization();
let reqwest_client = build_network_client(&config);
let (sync_network_tx, sync_network_rx) = mpsc::channel(500);
let cancellation_token = CancellationToken::new();
let ctrlc_cancellation_token = cancellation_token.clone();
@@ -185,6 +187,7 @@ async fn main() -> Result<()> {
match args.command {
Some(command) => match command {
Command::Radarr(_) | Command::Sonarr(_) | Command::Lidarr(_) | Command::Readarr(_) => {
let reqwest_client = build_network_client(&config);
if spinner_disabled {
start_cli_no_spinner(
config,
@@ -219,6 +222,7 @@ async fn main() -> Result<()> {
}
},
None => {
let reqwest_client = build_network_client(&config);
let app_nw = Arc::clone(&app);
std::thread::spawn(move || {
start_networking(sync_network_rx, &app_nw, cancellation_token, reqwest_client)
@@ -43,6 +43,8 @@ impl ProbeEnv {
.env("HOME", self.base.join("home"))
.env("XDG_CACHE_HOME", self.blocked_cache_dir())
.env("TMPDIR", self.base.join("fresh_tmp"))
.env("SSL_CERT_FILE", self.base.join("no_certs.crt"))
.env("SSL_CERT_DIR", self.base.join("no_certs_dir"))
.arg("--config-file")
.arg(self.base.join("config.yml"));
command
@@ -164,6 +166,8 @@ fn unset_home_does_not_panic_on_startup() {
.env_clear()
.env("PATH", std::env::var_os("PATH").unwrap())
.env("TMPDIR", env.base.join("fresh_tmp"))
.env("SSL_CERT_FILE", env.base.join("no_certs.crt"))
.env("SSL_CERT_DIR", env.base.join("no_certs_dir"))
.current_dir(&env.base)
.arg("--config-file")
.arg(env.base.join("config.yml"))
@@ -182,3 +186,51 @@ fn unset_home_does_not_panic_on_startup() {
"binary panicked instead of degrading gracefully: {stderr}"
);
}
#[cfg(target_os = "linux")]
#[test]
fn config_path_succeeds_without_loadable_tls_certificates() {
let env = ProbeEnv::new("config_path");
let mut command = env.command();
let assertion = command.arg("config-path").assert().success();
let output = assertion.get_output();
let stderr = str::from_utf8(&output.stderr).unwrap();
let stdout = str::from_utf8(&output.stdout).unwrap();
assert_eq!(
stdout.trim_end(),
env.base.join("config.yml").display().to_string(),
"config-path did not print the config file passed via --config-file"
);
assert!(
!stderr.contains("builder error"),
"config-path built the reqwest client despite needing no network: {stderr}"
);
assert!(
!stderr.contains("panicked"),
"binary panicked instead of degrading gracefully: {stderr}"
);
}
#[cfg(target_os = "linux")]
#[test]
fn servarr_command_without_loadable_tls_certificates_reports_builder_error() {
let env = ProbeEnv::new("servarr_builder_error");
let mut command = env.command();
let assertion = command
.args(["--disable-spinner", "radarr", "list", "movies"])
.assert()
.failure();
let stderr = str::from_utf8(&assertion.get_output().stderr).unwrap();
assert!(
stderr.contains("error: builder error"),
"network-bound command did not surface the client builder failure: {stderr}"
);
assert!(
!stderr.contains("panicked"),
"builder failure panicked instead of exiting cleanly: {stderr}"
);
}