diff --git a/src/storage.rs b/src/storage.rs index 92acfc2..35e123a 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -227,7 +227,12 @@ pub(crate) struct DiskStorage { impl DiskStorage { pub(crate) async fn new(path: PathBuf) -> Result { - 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