mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-08-30 22:44:48 +00:00
Implement better retry and use it while saving device
This commit is contained in:
parent
f713e2e092
commit
4e827e4f8a
3 changed files with 45 additions and 30 deletions
|
@ -101,7 +101,6 @@ impl Device {
|
|||
amr: vec!["Application".into()],
|
||||
};
|
||||
|
||||
|
||||
(encode_jwt(&claims), DEFAULT_VALIDITY.num_seconds())
|
||||
}
|
||||
}
|
||||
|
@ -116,8 +115,15 @@ impl Device {
|
|||
pub fn save(&mut self, conn: &DbConn) -> QueryResult<()> {
|
||||
self.updated_at = Utc::now().naive_utc();
|
||||
|
||||
diesel::replace_into(devices::table)
|
||||
.values(&*self).execute(&**conn).and(Ok(()))
|
||||
crate::util::retry(
|
||||
|| {
|
||||
diesel::replace_into(devices::table)
|
||||
.values(&*self)
|
||||
.execute(&**conn)
|
||||
},
|
||||
10,
|
||||
)
|
||||
.and(Ok(()))
|
||||
}
|
||||
|
||||
pub fn delete(self, conn: &DbConn) -> QueryResult<()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue