0
0
Fork 0
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:
Delta1925 2023-04-13 22:55:05 +02:00
parent 9efbaefd92
commit 4b445a6a96
No known key found for this signature in database
GPG key ID: 1C21ACE44193CB25
5 changed files with 18 additions and 4 deletions

View file

@ -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)
}