aboutsummaryrefslogtreecommitdiffstats
path: root/src/db.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-04-12 00:08:03 -0400
committerJesse Luehrs <doy@tozt.net>2020-04-12 00:08:03 -0400
commit236f06736e45c2a70f43589c9d447a0a3ef240b5 (patch)
treec390d4cbfec5223ac1aefe3947f8e1bb885757d2 /src/db.rs
parent91d1d1890bdc3ee75b69e00d5368c5b29a4f461c (diff)
downloadrbw-236f06736e45c2a70f43589c9d447a0a3ef240b5.tar.gz
rbw-236f06736e45c2a70f43589c9d447a0a3ef240b5.zip
improve error handling and reporting
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs4
1 files changed, 4 insertions, 0 deletions
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)?;