mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-03 16:28:10 +00:00
Attachment::save()
returns Result instead of bool (#161)
Returning a result instead of a bool as per #6
This commit is contained in:
parent
062ae4dd59
commit
fe473b9e75
2 changed files with 13 additions and 12 deletions
|
@ -53,13 +53,11 @@ use db::schema::attachments;
|
|||
|
||||
/// Database methods
|
||||
impl Attachment {
|
||||
pub fn save(&self, conn: &DbConn) -> bool {
|
||||
match diesel::replace_into(attachments::table)
|
||||
pub fn save(&self, conn: &DbConn) -> QueryResult<()> {
|
||||
diesel::replace_into(attachments::table)
|
||||
.values(self)
|
||||
.execute(&**conn) {
|
||||
Ok(1) => true, // One row inserted
|
||||
_ => false,
|
||||
}
|
||||
.execute(&**conn)
|
||||
.and(Ok(()))
|
||||
}
|
||||
|
||||
pub fn delete(self, conn: &DbConn) -> QueryResult<()> {
|
||||
|
@ -67,7 +65,7 @@ impl Attachment {
|
|||
use std::{thread, time};
|
||||
|
||||
let mut retries = 10;
|
||||
|
||||
|
||||
loop {
|
||||
match diesel::delete(
|
||||
attachments::table.filter(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue