mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 20:47:01 +01:00
Resolve upgrade in place error with cbor to json (#1028)
This commit is contained in:
parent
985462590b
commit
b20d531295
|
@ -277,20 +277,25 @@ impl<'a> DbTxn<'a> {
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let r: Result<Option<(_, _)>, ()> = data
|
if let Some((token, expiry)) = data.first() {
|
||||||
.first()
|
// token convert with json.
|
||||||
.map(|(token, expiry)| {
|
// If this errors, we specifically return Ok(None) because that triggers
|
||||||
// token convert with json.
|
// the cache to refetch the token.
|
||||||
let t = serde_json::from_slice(token.as_slice()).map_err(|e| {
|
match serde_json::from_slice(token.as_slice()) {
|
||||||
error!("json error -> {:?}", e);
|
Ok(t) => {
|
||||||
})?;
|
let e = u64::try_from(*expiry).map_err(|e| {
|
||||||
let e = u64::try_from(*expiry).map_err(|e| {
|
error!("u64 convert error -> {:?}", e);
|
||||||
error!("u64 convert error -> {:?}", e);
|
})?;
|
||||||
})?;
|
Ok(Some((t, e)))
|
||||||
Ok((t, e))
|
}
|
||||||
})
|
Err(e) => {
|
||||||
.transpose();
|
warn!("recoverable - json error -> {:?}", e);
|
||||||
r
|
Ok(None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_accounts(&self) -> Result<Vec<UnixUserToken>, ()> {
|
pub fn get_accounts(&self) -> Result<Vec<UnixUserToken>, ()> {
|
||||||
|
@ -314,14 +319,18 @@ impl<'a> DbTxn<'a> {
|
||||||
|
|
||||||
let data = data?;
|
let data = data?;
|
||||||
|
|
||||||
data.iter()
|
Ok(data
|
||||||
.map(|token| {
|
.iter()
|
||||||
|
// We filter map here so that anything invalid is skipped.
|
||||||
|
.filter_map(|token| {
|
||||||
// token convert with json.
|
// token convert with json.
|
||||||
serde_json::from_slice(token.as_slice()).map_err(|e| {
|
serde_json::from_slice(token.as_slice())
|
||||||
error!("get_accounts json error -> {:?}", e);
|
.map_err(|e| {
|
||||||
})
|
warn!("get_accounts json error -> {:?}", e);
|
||||||
|
})
|
||||||
|
.ok()
|
||||||
})
|
})
|
||||||
.collect()
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_account(&self, account: &UnixUserToken, expire: u64) -> Result<(), ()> {
|
pub fn update_account(&self, account: &UnixUserToken, expire: u64) -> Result<(), ()> {
|
||||||
|
@ -572,20 +581,25 @@ impl<'a> DbTxn<'a> {
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let r: Result<Option<(_, _)>, ()> = data
|
if let Some((token, expiry)) = data.first() {
|
||||||
.first()
|
// token convert with json.
|
||||||
.map(|(token, expiry)| {
|
// If this errors, we specifically return Ok(None) because that triggers
|
||||||
// token convert with json.
|
// the cache to refetch the token.
|
||||||
let t = serde_json::from_slice(token.as_slice()).map_err(|e| {
|
match serde_json::from_slice(token.as_slice()) {
|
||||||
error!("json error -> {:?}", e);
|
Ok(t) => {
|
||||||
})?;
|
let e = u64::try_from(*expiry).map_err(|e| {
|
||||||
let e = u64::try_from(*expiry).map_err(|e| {
|
error!("u64 convert error -> {:?}", e);
|
||||||
error!("u64 convert error -> {:?}", e);
|
})?;
|
||||||
})?;
|
Ok(Some((t, e)))
|
||||||
Ok((t, e))
|
}
|
||||||
})
|
Err(e) => {
|
||||||
.transpose();
|
warn!("recoverable - json error -> {:?}", e);
|
||||||
r
|
Ok(None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_group_members(&self, g_uuid: &str) -> Result<Vec<UnixUserToken>, ()> {
|
pub fn get_group_members(&self, g_uuid: &str) -> Result<Vec<UnixUserToken>, ()> {
|
||||||
|
@ -643,15 +657,18 @@ impl<'a> DbTxn<'a> {
|
||||||
|
|
||||||
let data = data?;
|
let data = data?;
|
||||||
|
|
||||||
data.iter()
|
Ok(data
|
||||||
.map(|token| {
|
.iter()
|
||||||
|
.filter_map(|token| {
|
||||||
// token convert with json.
|
// token convert with json.
|
||||||
// debug!("{:?}", token);
|
// debug!("{:?}", token);
|
||||||
serde_json::from_slice(token.as_slice()).map_err(|e| {
|
serde_json::from_slice(token.as_slice())
|
||||||
error!("json error -> {:?}", e);
|
.map_err(|e| {
|
||||||
})
|
error!("json error -> {:?}", e);
|
||||||
|
})
|
||||||
|
.ok()
|
||||||
})
|
})
|
||||||
.collect()
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_group(&self, grp: &UnixGroupToken, expire: u64) -> Result<(), ()> {
|
pub fn update_group(&self, grp: &UnixGroupToken, expire: u64) -> Result<(), ()> {
|
||||||
|
|
Loading…
Reference in a new issue