fix: Marked Radarr studios as nullable to prevent crashes

This commit is contained in:
2025-08-07 20:05:05 -06:00
parent 02870043ec
commit f08f255a46
8 changed files with 26 additions and 13 deletions
@@ -615,8 +615,13 @@ mod tests {
#[test]
fn test_movies_sorting_options_studio() {
let expected_cmp_fn: fn(&Movie, &Movie) -> Ordering =
|a, b| a.studio.to_lowercase().cmp(&b.studio.to_lowercase());
let expected_cmp_fn: fn(&Movie, &Movie) -> Ordering = |a, b| {
a.studio
.as_ref()
.unwrap_or(&String::new())
.to_lowercase()
.cmp(&b.studio.as_ref().unwrap_or(&String::new()).to_lowercase())
};
let mut expected_movies_vec = movies_vec();
expected_movies_vec.sort_by(expected_cmp_fn);
@@ -856,7 +861,7 @@ mod tests {
name: "English".to_owned(),
},
size_on_disk: 1024,
studio: "Studio 1".to_owned(),
studio: Some("Studio 1".to_owned()),
year: 2024,
monitored: false,
runtime: 12.into(),
@@ -873,7 +878,7 @@ mod tests {
name: "Chinese".to_owned(),
},
size_on_disk: 2048,
studio: "Studio 2".to_owned(),
studio: Some("Studio 2".to_owned()),
year: 1998,
monitored: false,
runtime: 60.into(),
@@ -890,7 +895,7 @@ mod tests {
name: "Japanese".to_owned(),
},
size_on_disk: 512,
studio: "studio 3".to_owned(),
studio: Some("studio 3".to_owned()),
year: 1954,
monitored: true,
runtime: 120.into(),
+7 -1
View File
@@ -223,7 +223,13 @@ fn movies_sorting_options() -> Vec<SortOption<Movie>> {
},
SortOption {
name: "Studio",
cmp_fn: Some(|a, b| a.studio.to_lowercase().cmp(&b.studio.to_lowercase())),
cmp_fn: Some(|a, b| {
a.studio
.as_ref()
.unwrap_or(&String::new())
.to_lowercase()
.cmp(&b.studio.as_ref().unwrap_or(&String::new()).to_lowercase())
}),
},
SortOption {
name: "Runtime",
@@ -327,7 +327,7 @@ pub(in crate::handlers::radarr_handlers) mod utils {
status: "Downloaded".to_owned(),
overview: "Blah blah blah".to_owned(),
path: "/nfs/movies".to_owned(),
studio: "21st Century Alex".to_owned(),
studio: Some("21st Century Alex".to_owned()),
genres: genres(),
year: 2023,
monitored: true,
+3 -3
View File
@@ -1165,7 +1165,7 @@ mod tests {
name: "English".to_owned(),
},
size_on_disk: 1024,
studio: "Studio 1".to_owned(),
studio: Some("Studio 1".to_owned()),
year: 2024,
monitored: false,
runtime: 12.into(),
@@ -1182,7 +1182,7 @@ mod tests {
name: "Chinese".to_owned(),
},
size_on_disk: 2048,
studio: "Studio 2".to_owned(),
studio: Some("Studio 2".to_owned()),
year: 1998,
monitored: false,
runtime: 60.into(),
@@ -1199,7 +1199,7 @@ mod tests {
name: "Japanese".to_owned(),
},
size_on_disk: 512,
studio: "studio 3".to_owned(),
studio: Some("studio 3".to_owned()),
year: 1954,
monitored: true,
runtime: 120.into(),
+1 -1
View File
@@ -308,7 +308,7 @@ pub struct Movie {
pub status: String,
pub overview: String,
pub path: String,
pub studio: String,
pub studio: Option<String>,
pub genres: Vec<String>,
#[serde(deserialize_with = "super::from_i64")]
pub year: i64,
+1
View File
@@ -1206,6 +1206,7 @@ impl Network<'_, '_> {
} = movie_response;
let (hours, minutes) = convert_runtime(runtime);
let size = convert_to_gb(size_on_disk);
let studio = studio.clone().unwrap_or_default();
let quality_profile = app
.data
.radarr_data
+1 -1
View File
@@ -4082,7 +4082,7 @@ mod test {
status: "Downloaded".to_owned(),
overview: "Blah blah blah".to_owned(),
path: "/nfs/movies".to_owned(),
studio: "21st Century Alex".to_owned(),
studio: Some("21st Century Alex".to_owned()),
genres: genres(),
year: 2023,
monitored: true,
+2 -1
View File
@@ -98,6 +98,7 @@ fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
app.tick_count % app.ticks_until_scroll == 0,
);
let monitored = if movie.monitored { "🏷" } else { "" };
let studio = movie.studio.clone().unwrap_or_default();
let (hours, minutes) = convert_runtime(movie.runtime);
let file_size: f64 = convert_to_gb(movie.size_on_disk);
let certification = movie.certification.clone().unwrap_or_default();
@@ -128,7 +129,7 @@ fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
Row::new(vec![
Cell::from(movie.title.to_string()),
Cell::from(movie.year.to_string()),
Cell::from(movie.studio.to_string()),
Cell::from(studio),
Cell::from(format!("{hours}h {minutes}m")),
Cell::from(certification),
Cell::from(movie.original_language.name.to_owned()),