papayu/src-tauri/src/commands/folder_links.rs
Yuriy e76236dc55 Initial commit: papa-yu v2.4.4
- Schema version (x_schema_version, schema_hash) в prompt/trace
- Кеш read/search/logs/env (ContextCache) в plan-цикле
- Контекст-диета: MAX_FILES=8, MAX_FILE_CHARS=20k, MAX_TOTAL_CHARS=120k
- Plan→Apply двухфазность, NO_CHANGES, path sanitization
- Protected paths, content validation, EOL normalization
- Trace (PAPAYU_TRACE), redaction (PAPAYU_TRACE_RAW)
- Preview diff, undo/redo, transactional apply

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-01-31 11:33:19 +03:00

31 lines
857 B
Rust

use serde::{Deserialize, Serialize};
use std::fs;
use std::path::Path;
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct FolderLinks {
pub paths: Vec<String>,
}
const FILENAME: &str = "folder_links.json";
pub fn load_folder_links(app_data_dir: &Path) -> FolderLinks {
let p = app_data_dir.join(FILENAME);
if let Ok(s) = fs::read_to_string(&p) {
if let Ok(links) = serde_json::from_str::<FolderLinks>(&s) {
return links;
}
}
FolderLinks::default()
}
pub fn save_folder_links(app_data_dir: &Path, links: &FolderLinks) -> Result<(), String> {
fs::create_dir_all(app_data_dir).map_err(|e| e.to_string())?;
let p = app_data_dir.join(FILENAME);
fs::write(
&p,
serde_json::to_string_pretty(links).map_err(|e| e.to_string())?,
)
.map_err(|e| e.to_string())
}