Add VaultEntry.snippet field (first ~160 chars of content, markdown-stripped). Implement scan_vault_cached() with git-based incremental caching: - Writes .laputa-cache.json to vault dir - On same HEAD: returns cached entries + uncommitted new files - On different HEAD: re-parses only changed files via git diff - Falls back to full scan when git unavailable or cache corrupt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
81 lines
2.2 KiB
Rust
81 lines
2.2 KiB
Rust
pub mod frontmatter;
|
|
pub mod git;
|
|
pub mod vault;
|
|
|
|
use git::{GitCommit, ModifiedFile};
|
|
use vault::VaultEntry;
|
|
use frontmatter::FrontmatterValue;
|
|
|
|
#[tauri::command]
|
|
fn list_vault(path: String) -> Result<Vec<VaultEntry>, String> {
|
|
vault::scan_vault_cached(&path)
|
|
}
|
|
|
|
#[tauri::command]
|
|
fn get_note_content(path: String) -> Result<String, String> {
|
|
vault::get_note_content(&path)
|
|
}
|
|
|
|
#[tauri::command]
|
|
fn update_frontmatter(path: String, key: String, value: FrontmatterValue) -> Result<String, String> {
|
|
vault::update_frontmatter(&path, &key, value)
|
|
}
|
|
|
|
#[tauri::command]
|
|
fn delete_frontmatter_property(path: String, key: String) -> Result<String, String> {
|
|
vault::delete_frontmatter_property(&path, &key)
|
|
}
|
|
|
|
#[tauri::command]
|
|
fn get_file_history(vault_path: String, path: String) -> Result<Vec<GitCommit>, String> {
|
|
git::get_file_history(&vault_path, &path)
|
|
}
|
|
|
|
#[tauri::command]
|
|
fn get_modified_files(vault_path: String) -> Result<Vec<ModifiedFile>, String> {
|
|
git::get_modified_files(&vault_path)
|
|
}
|
|
|
|
#[tauri::command]
|
|
fn get_file_diff(vault_path: String, path: String) -> Result<String, String> {
|
|
git::get_file_diff(&vault_path, &path)
|
|
}
|
|
|
|
#[tauri::command]
|
|
fn git_commit(vault_path: String, message: String) -> Result<String, String> {
|
|
git::git_commit(&vault_path, &message)
|
|
}
|
|
|
|
#[tauri::command]
|
|
fn git_push(vault_path: String) -> Result<String, String> {
|
|
git::git_push(&vault_path)
|
|
}
|
|
|
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
pub fn run() {
|
|
tauri::Builder::default()
|
|
.setup(|app| {
|
|
if cfg!(debug_assertions) {
|
|
app.handle().plugin(
|
|
tauri_plugin_log::Builder::default()
|
|
.level(log::LevelFilter::Info)
|
|
.build(),
|
|
)?;
|
|
}
|
|
Ok(())
|
|
})
|
|
.invoke_handler(tauri::generate_handler![
|
|
list_vault,
|
|
get_note_content,
|
|
update_frontmatter,
|
|
delete_frontmatter_property,
|
|
get_file_history,
|
|
get_modified_files,
|
|
get_file_diff,
|
|
git_commit,
|
|
git_push
|
|
])
|
|
.run(tauri::generate_context!())
|
|
.expect("error while running tauri application");
|
|
}
|