diff --git a/src/storage.rs b/src/storage.rs index 2327b59..e92fb63 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -110,7 +110,12 @@ impl Storage { } } pub fn from_db(passphrase: String) -> io::Result { - // TODO: throw error if it's not inited + if !Storage::is_inited() { + return Err(io::Error::new( + io::ErrorKind::Other, + "Storage is not initialized" + )); + } let encoder = Encoder::from(passphrase); // TODO: throw error is password is incorrect let file = fs::File::open(&*STORAGE_PATH)?; @@ -173,8 +178,11 @@ impl Storage { } pub fn is_inited() -> bool { + // TODO: check db + // TODO check git let path = Path::new(&*STORAGE_FOLDER); return path.exists(); + } pub fn ids(&self) -> Vec {