mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-01-04 10:20:26 +01:00
Fix a bug in refactoring the storage layer.
Attempting to load from disk when the file does not exist should not return an error and should continue with an empty set of tokens.
This commit is contained in:
@@ -227,7 +227,12 @@ pub(crate) struct DiskStorage {
|
||||
|
||||
impl DiskStorage {
|
||||
pub(crate) async fn new(path: PathBuf) -> Result<Self, io::Error> {
|
||||
let tokens = JSONTokens::load_from_file(&path).await?;
|
||||
let tokens = match JSONTokens::load_from_file(&path).await {
|
||||
Ok(tokens) => tokens,
|
||||
Err(e) if e.kind() == io::ErrorKind::NotFound => JSONTokens::new(),
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
|
||||
// Writing to disk will happen in a separate task. This means in the
|
||||
// common case returning a token to the user will not be required to
|
||||
// wait for disk i/o. We communicate with a dedicated writer task via a
|
||||
|
||||
Reference in New Issue
Block a user