diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-07-29 00:33:56 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-07-29 00:33:56 +0200 |
| commit | 7f84d10288deffcbf4cc71511f5605a3442e4955 (patch) | |
| tree | ed6862ef6faacf601171e6575c1e17b2eb5cd30d /cli/src | |
| parent | 157790ff3452be04b6a14c1bec7aab821a4a8725 (diff) | |
| download | money-7f84d10288deffcbf4cc71511f5605a3442e4955.tar.gz | |
write post with hash as path
Diffstat (limited to 'cli/src')
| -rw-r--r-- | cli/src/main.rs | 10 |
1 files changed, 7 insertions, 3 deletions
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<Vec<Post>> { @@ -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(()) } } |
