mirror of
https://git.verdigado.com/NB-Public/simple-wkd.git
synced 2024-12-06 14:52:41 +01:00
Improve file checking
This commit is contained in:
parent
9efbaefd92
commit
4b445a6a96
5 changed files with 18 additions and 4 deletions
12
src/utils.rs
12
src/utils.rs
|
@ -1,10 +1,10 @@
|
|||
use crate::errors::Error;
|
||||
use crate::VARIANT;
|
||||
use crate::{PATH, PENDING, VARIANT};
|
||||
|
||||
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
||||
use sequoia_net::wkd::Url;
|
||||
use sequoia_openpgp::{parse::Parse, Cert};
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! pending_path {
|
||||
|
@ -50,3 +50,11 @@ pub fn get_user_file_path(email: &str) -> Result<PathBuf, Error> {
|
|||
Err(_) => Err(Error::ParseMail),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn key_exists(email: &str) -> Result<bool, Error> {
|
||||
let path = get_user_file_path(email)?;
|
||||
if !pending_path!().join(path).is_file() {
|
||||
return Err(Error::MissingKey);
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue