25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(sync): replace AI configs from legacy snapshots
t8y271575c32de41
diff --git a/crates/dbx-core/src/cloud_sync.rs b/crates/dbx-core/src/cloud_sync.rsindex c00226962d..baa288fc25 100644--- a/crates/dbx-core/src/cloud_sync.rs+++ b/crates/dbx-core/src/cloud_sync.rs@@ -794,7 +794,9 @@ async fn apply_sensitive_payload(storage: &Storage, payload: &SensitiveSyncPaylo// New format: save directly (empty = all configs were deleted)storage.save_ai_configs(configs).await?;} else if let Some(old_config) = &payload.ai_config {- // Legacy format: migrate then save+ // A legacy snapshot still represents the complete AI configuration state.+ // Replace local configs just like the new list format so a generated ID+ // cannot conflict with an existing config that has the same name.let provider_name = old_config.provider.as_str().to_string();let item = AiConfigItem {id: AiConfigItem::new_id(),@@ -802,7 +804,7 @@ async fn apply_sensitive_payload(storage: &Storage, payload: &SensitiveSyncPaylois_default: true,config: old_config.clone(),};- storage.save_ai_config_item(&item).await?;+ storage.save_ai_configs(&[item]).await?;}if let Some(profiles) = &payload.tunnel_profiles {storage.save_tunnel_profiles(profiles).await?;@@ -1579,4 +1581,30 @@ mod tests {assert_eq!(loaded.len(), 1);assert_eq!(loaded[0].name, "synced");}++ #[tokio::test]+ async fn sensitive_payload_legacy_ai_config_replaces_local_configs_with_same_name() {+ let storage = Storage::open(&temp_db_path("ai-cfg-legacy-replace")).await.unwrap();+ storage.save_ai_config_item(&make_test_config("openai", true)).await.unwrap();+ storage.save_ai_config_item(&make_test_config("local-only", false)).await.unwrap();++ let mut legacy_config = make_test_config("unused", true).config;+ legacy_config.model = "snapshot-model".to_string();+ let payload = SensitiveSyncPayload {+ connection_secrets: vec![],+ ai_configs: None,+ ai_config: Some(legacy_config),+ tunnel_profiles: None,+ };++ apply_sensitive_payload(&storage, &payload).await.unwrap();+ // Reapplying the same old snapshot must not collide with the generated ID.+ apply_sensitive_payload(&storage, &payload).await.unwrap();++ let loaded = storage.load_ai_configs().await.unwrap();+ assert_eq!(loaded.len(), 1);+ assert_eq!(loaded[0].name, "openai");+ assert_eq!(loaded[0].config.model, "snapshot-model");+ assert!(loaded[0].is_default);+ }}