From d5c728136720e66de2dd29087861131d227390a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=BDubom=C3=ADr=20Kur=C4=8D=C3=A1k?= Date: Fri, 31 Jul 2026 15:14:52 +0200 Subject: [PATCH] feat: replace create_subfolder_enabled with torrent_content_layout --- src/model/app.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/model/app.rs b/src/model/app.rs index a76b672..07df34d 100644 --- a/src/model/app.rs +++ b/src/model/app.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, path::PathBuf}; use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor}; use serde_with::skip_serializing_none; -use crate::model::IntOrStr; +use crate::model::{ContentLayout, IntOrStr}; /// qBittorrent and dependency version information. #[derive(Debug, Clone, serde::Deserialize, PartialEq, Eq)] @@ -41,8 +41,8 @@ pub struct ProcessInfo { pub struct Preferences { /// Currently selected language (e.g. en_GB for English) pub locale: Option, - /// True if a subfolder should be created when adding a torrent - pub create_subfolder_enabled: Option, + /// Default content layout for newly added torrents. + pub torrent_content_layout: Option, /// True if torrents should be added in a Paused state pub start_paused_enabled: Option, /// TODO @@ -482,4 +482,24 @@ mod tests { assert!(json.contains("auto_tmm_enabled")); assert!(!json.contains("null"), "None fields should be skipped, got: {json}"); } + + #[test] + fn preferences_round_trips_torrent_content_layout() { + for (layout, api_value) in [ + (ContentLayout::Original, "Original"), + (ContentLayout::Subfolder, "Subfolder"), + (ContentLayout::NoSubfolder, "NoSubfolder"), + ] { + let expected = serde_json::json!({"torrent_content_layout": api_value}); + let prefs = Preferences { + torrent_content_layout: Some(layout), + ..Default::default() + }; + + assert_eq!(serde_json::to_value(&prefs).unwrap(), expected); + + let prefs: Preferences = serde_json::from_value(expected).unwrap(); + assert_eq!(prefs.torrent_content_layout, Some(layout)); + } + } }