From 7f84d10288deffcbf4cc71511f5605a3442e4955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Thu, 29 Jul 2021 00:33:56 +0200 Subject: write post with hash as path --- cli/src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'cli') diff --git a/cli/src/main.rs b/cli/src/main.rs index 656107d..8f9cccf 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -53,6 +53,7 @@ impl Store { }) } + //TODO check if hash matches //TODO Result //TODO overkill? maybe we can use subfolders later on fn open_dir(dir: &Path) -> Option> { @@ -69,13 +70,16 @@ impl Store { Some(res) } - fn write(&self) { + fn write(&self) -> std::io::Result<()> { for post in &self.posts { let mut h = XxHash64::default(); post.hash(&mut h); - let file = h.finish(); - println!("{}: {:?}", file, post); + let h = h.finish(); + let mut path = self.root.clone(); + path.push(format!("{}", h)); + post.write(&path)?; } + Ok(()) } } -- cgit v1.2.1