From 236f06736e45c2a70f43589c9d447a0a3ef240b5 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 12 Apr 2020 00:08:03 -0400 Subject: improve error handling and reporting --- src/db.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/db.rs') diff --git a/src/db.rs b/src/db.rs index 7e94d73..a750693 100644 --- a/src/db.rs +++ b/src/db.rs @@ -45,6 +45,8 @@ impl Db { // XXX need to make this atomic pub fn save(&self, email: &str) -> Result<()> { let filename = Self::filename(email); + // unwrap is safe here because Self::filename is explicitly + // constructed as a filename in a directory std::fs::create_dir_all(filename.parent().unwrap()) .context(crate::error::SaveDb)?; let mut fh = @@ -61,6 +63,8 @@ impl Db { // XXX need to make this atomic pub async fn save_async(&self, email: &str) -> Result<()> { let filename = Self::filename(email); + // unwrap is safe here because Self::filename is explicitly + // constructed as a filename in a directory tokio::fs::create_dir_all(filename.parent().unwrap()) .await .context(crate::error::SaveDbAsync)?; -- cgit v1.2.3-54-g00ecf