feat(kon): add storage crate — SQLite schema, CRUD operations
- SQLite via sqlx 0.8 with runtime-tokio - Schema: transcripts, segments, tasks, task_lists, settings tables - Full CRUD for transcripts (insert, get, list, delete) - Full CRUD for tasks (insert, list, complete, delete) - Settings key-value store (insert/replace, get) - File storage paths: app_data_dir, database_path, recordings_dir - 3 async tests passing against in-memory SQLite, clippy clean Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
26
crates/storage/src/file_storage.rs
Normal file
26
crates/storage/src/file_storage.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Resolve the app data directory.
|
||||
/// Windows: %LOCALAPPDATA%/kon
|
||||
/// Unix: ~/.kon
|
||||
pub fn app_data_dir() -> PathBuf {
|
||||
if cfg!(target_os = "windows") {
|
||||
let local_app_data =
|
||||
std::env::var("LOCALAPPDATA").unwrap_or_else(|_| ".".to_string());
|
||||
PathBuf::from(local_app_data).join("kon")
|
||||
} else {
|
||||
let home =
|
||||
std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string());
|
||||
PathBuf::from(home).join(".kon")
|
||||
}
|
||||
}
|
||||
|
||||
/// Path to the SQLite database file.
|
||||
pub fn database_path() -> PathBuf {
|
||||
app_data_dir().join("kon.db")
|
||||
}
|
||||
|
||||
/// Directory for saved audio recordings.
|
||||
pub fn recordings_dir() -> PathBuf {
|
||||
app_data_dir().join("recordings")
|
||||
}
|
||||
Reference in New Issue
Block a user