My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: workspace initialization uses canonical path

+17 -19
+1
Cargo.lock
··· 2312 2312 "serde", 2313 2313 "signal-hook 0.4.3", 2314 2314 "strum 0.28.0", 2315 + "tempfile", 2315 2316 "tokio", 2316 2317 "tokio-util", 2317 2318 "tracing",
+3
Cargo.toml
··· 86 86 anyhow = "1.0.102" 87 87 vergen-gix = {version = "9.1.0", features = ["build", "cargo"]} 88 88 89 + [dev-dependencies] 90 + tempfile = "3" 91 + 89 92 # patch egui_graphs to have egui 0.34.1 90 93 [patch.crates-io] 91 94 egui_graphs = { git = "https://github.com/suri-codes/egui_graphs", rev = "3327417007520300782574e3d6bc377bbafa8b5a" }
+13 -19
src/types/workspace.rs
··· 52 52 pub async fn initialize(path: impl Into<PathBuf>) -> Result<Self> { 53 53 let path = path.into(); 54 54 55 - // create the .filaments folder 56 55 let filaments_dir = path.join(".filaments"); 57 56 57 + // create the dir 58 58 create_dir_all(&filaments_dir) 59 59 .await 60 60 .context("Failed to create the filaments directory!")?; 61 61 62 - // create the database inside there 62 + let filaments_dir = filaments_dir.canonicalize()?; 63 + 63 64 File::create(filaments_dir.join("filaments.db")).await?; 64 65 65 - Ok(Self::instansiate(path).await.expect( 66 - "Invariant broken. This instantiation call must always work 67 - since we just initialized the workspace.", 66 + Ok(Self::instansiate(&path).await.expect( 67 + "Invariant broken. This instantiation call must always work \ 68 + since we just initialized the workspace.", 68 69 )) 69 70 } 70 71 } 71 72 72 73 #[cfg(test)] 73 74 mod tests { 74 - use std::{ 75 - fs::{File, create_dir_all}, 76 - path::PathBuf, 77 - }; 78 - 79 - use dto::NanoId; 80 75 81 76 use crate::types::Workspace; 82 77 83 78 #[tokio::test] 84 79 async fn test_instantiation() { 85 - let path = PathBuf::from("/tmp/filaments/.filaments/filaments.db"); 86 - create_dir_all(path.parent().unwrap()).unwrap(); 87 - let _ = File::create(&path).unwrap(); 88 - let _ws = Workspace::instansiate(&path.parent().unwrap().parent().unwrap()) 89 - .await 90 - .unwrap(); 80 + let tmp = tempfile::tempdir().unwrap(); 81 + let filaments_dir = tmp.path().join(".filaments"); 82 + std::fs::create_dir_all(&filaments_dir).unwrap(); 83 + std::fs::File::create(filaments_dir.join("filaments.db")).unwrap(); 84 + let _ws = Workspace::instansiate(tmp.path()).await.unwrap(); 91 85 } 92 86 93 87 #[tokio::test] 94 88 async fn test_initialization() { 95 - let path = PathBuf::from(format!("/tmp/filaments/{}", NanoId::default())); 96 - 89 + let tmp = tempfile::tempdir().unwrap(); 90 + let path = tmp.path().join("workspace"); 97 91 Workspace::initialize(path) 98 92 .await 99 93 .expect("Should initialize just fine");