diff options
author | Daniel Schadt <kingdread@gmx.de> | 2019-12-20 17:04:45 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2019-12-20 17:04:45 +0100 |
commit | 087580b3c269dbc5b2298ff6f4590f010279d339 (patch) | |
tree | f0fb223ab5be75847ea35e16efacc6f2db5df475 /src/api | |
parent | 89c2ac305967ba03ef9b704e621ff0ff886ca308 (diff) | |
download | kondou-087580b3c269dbc5b2298ff6f4590f010279d339.tar.gz kondou-087580b3c269dbc5b2298ff6f4590f010279d339.tar.bz2 kondou-087580b3c269dbc5b2298ff6f4590f010279d339.zip |
don't error when cache value can't be deserialized
The cache is meant to help out by saving old responses. If those
responses do not conform anymore to an updated struct definition, the
whole application should not crash. Instead, the value is silently
ignored and then overwritten by the proper value that has been fetched
from the API.
That way, users don't have to manually clear out the cache if a new API
schema or new features are released.
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/mod.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/api/mod.rs b/src/api/mod.rs index 27f0da1..ffed5ea 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -123,7 +123,7 @@ impl Api { P: AsRef<Path>, { match self.cache.get(name.as_ref())? { - Some(data) => Ok(serde_json::from_slice(&data)?), + Some(data) => serde_json::from_slice(&data).or(Ok(None)), None => Ok(None), } } |