Update cache to not fail on read error

pull/118/head
Chip Senkbeil 2 years ago
parent 33a30d98f0
commit 5e1b6e7c51
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -18,6 +18,13 @@ pub struct Cache {
}
impl Cache {
pub fn new(custom_path: impl Into<Option<PathBuf>>) -> Self {
Self {
file: CacheFile::new(custom_path),
data: CacheData::default(),
}
}
/// Loads the cache from the specified file path, or default user-local cache path,
/// constructing data from the default cache if not found
pub async fn read_from_disk_or_default(

@ -233,7 +233,10 @@ impl ClientSubcommand {
}
async fn async_run(self, config: ClientConfig) -> CliResult {
let mut cache = Cache::read_from_disk_or_default(self.cache_path().to_path_buf()).await?;
// If we get an error, just default anyway
let mut cache = Cache::read_from_disk_or_default(self.cache_path().to_path_buf())
.await
.unwrap_or_else(|_| Cache::new(self.cache_path().to_path_buf()));
match self {
Self::Action {

Loading…
Cancel
Save