Add resumable background model downloads

This commit is contained in:
Georg Bauer
2026-07-24 13:10:04 +02:00
parent 62e7752ec7
commit 952fb79edc
12 changed files with 1265 additions and 115 deletions

View File

@@ -14,7 +14,7 @@ pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");
pub struct AppPreferences {
pub id: i32,
pub selected_model: String,
pub dflash_enabled: bool,
pub dspark_enabled: bool,
pub idle_timeout_minutes: i32,
}
@@ -23,7 +23,7 @@ impl Default for AppPreferences {
Self {
id: 1,
selected_model: "deepseek-v4-flash".into(),
dflash_enabled: false,
dspark_enabled: false,
idle_timeout_minutes: 10,
}
}
@@ -33,7 +33,7 @@ impl Default for AppPreferences {
#[diesel(table_name = preferences)]
struct PreferenceChanges<'a> {
selected_model: &'a str,
dflash_enabled: bool,
dspark_enabled: bool,
idle_timeout_minutes: i32,
}
@@ -135,13 +135,13 @@ impl Database {
pub fn update_preferences(
&mut self,
selected_model: &str,
dflash_enabled: bool,
dspark_enabled: bool,
idle_timeout_minutes: i32,
) -> Result<AppPreferences, String> {
diesel::update(preferences::table.find(1))
.set(PreferenceChanges {
selected_model,
dflash_enabled,
dspark_enabled,
idle_timeout_minutes,
})
.returning(AppPreferences::as_returning())
@@ -200,7 +200,7 @@ mod tests {
let preferences = database.load_preferences().unwrap();
assert_eq!(preferences.selected_model, "deepseek-v4-flash");
assert!(!preferences.dflash_enabled);
assert!(!preferences.dspark_enabled);
assert_eq!(preferences.idle_timeout_minutes, 10);
assert!(database.update_preferences("glm-5.2", true, 30).is_err());
assert!(