commit b75f38033b7f18157c4db493087ef72fd36e7b01
parent 06522c9ac064e7b7ac2bcaa9bf6743896c198e1c
Author: Daniel GarcĂa <dani-garcia@users.noreply.github.com>
Date: Tue, 5 Feb 2019 15:31:07 +0100
Merge pull request #385 from mprasil/update_revision_retry
Retry updating revision - fixes #383
Diffstat:
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs
@@ -842,7 +842,7 @@ fn move_cipher_selected(data: JsonUpcase<MoveCipherData>, headers: Headers, conn
}
for uuid in data.Ids {
- let mut cipher = match Cipher::find_by_uuid(&uuid, &conn) {
+ let cipher = match Cipher::find_by_uuid(&uuid, &conn) {
Some(cipher) => cipher,
None => err!("Cipher doesn't exist"),
};
@@ -853,12 +853,11 @@ fn move_cipher_selected(data: JsonUpcase<MoveCipherData>, headers: Headers, conn
// Move cipher
cipher.move_to_folder(data.FolderId.clone(), &user_uuid, &conn)?;
- cipher.save(&conn)?;
nt.send_cipher_update(
UpdateType::CipherUpdate,
&cipher,
- &User::update_uuid_revision(&user_uuid, &conn),
+ &[user_uuid.clone()]
);
}
diff --git a/src/db/models/user.rs b/src/db/models/user.rs
@@ -184,10 +184,12 @@ impl User {
pub fn update_revision(&mut self, conn: &DbConn) -> EmptyResult {
self.updated_at = Utc::now().naive_utc();
- diesel::update(users::table.filter(users::uuid.eq(&self.uuid)))
- .set(users::updated_at.eq(&self.updated_at))
- .execute(&**conn)
- .map_res("Error updating user revision")
+ crate::util::retry( || {
+ diesel::update(users::table.filter(users::uuid.eq(&self.uuid)))
+ .set(users::updated_at.eq(&self.updated_at))
+ .execute(&**conn)
+ }, 10)
+ .map_res("Error updating user revision")
}
pub fn find_by_mail(mail: &str, conn: &DbConn) -> Option<Self> {