feat(transfer): persist reusable transfer tasks

This commit is contained in:
lizzzzz777 authored and GitHub committed 2026-08-14 18:25:05 +08:00
1 parent 1a10db4c18
commit 05361eb40d
26 files changed
+2628 -241

No files matched your search

+14
View File
@@ -28,6 +28,7 @@ const STORAGE_DB_FILE_NAME: &str = "dbx.db";
const APP_STATE_EDITOR_SETTINGS_KEY: &str = "editor_settings";
const APP_STATE_OPEN_TABS_KEY: &str = "open_tabs";
const APP_STATE_SAVED_SQL_EDITOR_POSITIONS_KEY: &str = "saved_sql_editor_positions";
const APP_STATE_TRANSFER_TASK_LIBRARY_KEY: &str = "transfer_task_library";
const MCP_GLOBAL_POLICY_KEY: &str = "mcp_global_policy";
const MAX_RETRIES_KEY: &str = "max_retries";
const APP_STATE_AI_GLOBAL_INSTRUCTIONS_KEY: &str = "ai_global_custom_instructions";
@@ -1727,6 +1728,16 @@ impl Storage {
self.load_app_state_value(APP_STATE_SAVED_SQL_EDITOR_POSITIONS_KEY).await
}
/// Persist the saved data-transfer task library (folders + task configs) as
/// one JSON document, mirroring the editor-settings app-state pattern.
pub async fn save_transfer_task_library(&self, library: &serde_json::Value) -> Result<(), String> {
self.save_app_state_value(APP_STATE_TRANSFER_TASK_LIBRARY_KEY, library).await
}
pub async fn load_transfer_task_library(&self) -> Result<Option<serde_json::Value>, String> {
self.load_app_state_value(APP_STATE_TRANSFER_TASK_LIBRARY_KEY).await
}
pub async fn save_ai_global_custom_instructions(&self, content: &str) -> Result<(), String> {
let trimmed = content.trim();
if trimmed.chars().count() > 8000 {
@@ -5413,6 +5424,8 @@ mod tests {
.save_saved_sql_editor_positions(&serde_json::json!([{ "savedSqlId": "file-1", "updatedAt": 1 }]))
.await
.unwrap();
let transfer_task_library = serde_json::json!({ "version": 1, "folders": [], "tasks": [] });
storage.save_transfer_task_library(&transfer_task_library).await.unwrap();
assert_eq!(
storage.load_editor_settings().await.unwrap(),
@@ -5450,6 +5463,7 @@ mod tests {
storage.load_saved_sql_editor_positions().await.unwrap(),
Some(serde_json::json!([{ "savedSqlId": "file-1", "updatedAt": 1 }]))
);
assert_eq!(storage.load_transfer_task_library().await.unwrap(), Some(transfer_task_library));
assert_eq!(storage.load_password_hash().await.unwrap(), Some("hash-4".to_string()));
assert_eq!(
storage.load_desktop_settings().await.unwrap(),