From 19f4a289e500a554cb3faabb8fbc427904e56e1c Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Tue, 26 May 2026 16:11:00 -0400 Subject: [PATCH] fix: config --- cosmic-config/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cosmic-config/src/lib.rs b/cosmic-config/src/lib.rs index 92eef09c..1396b5cb 100644 --- a/cosmic-config/src/lib.rs +++ b/cosmic-config/src/lib.rs @@ -328,7 +328,16 @@ impl Config { } /// Get data for the given application name and config version. + /// pub fn new_state(name: &str, version: u64) -> Result { pub fn new_data(name: &str, version: u64) -> Result { + Self::new_data_inner(name, version, true) + } + + pub fn new_data_inner( + name: &str, + version: u64, + look_for_previous: bool, + ) -> Result { // Look for [name]/v[version] let path = sanitize_name(name)?.join(format!("v{}", version)); @@ -342,6 +351,13 @@ impl Config { Ok(Self { system_path: None, user_path: Some(user_path), + previous: if version > 1 && look_for_previous { + Self::new_data_inner(name, version - 1, false) + .ok() + .map(Box::new) + } else { + None + }, }) }