Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-26 05:50:29 +01:00
WAL journal mode and delete retry added
Dieser Commit ist enthalten in:
Ursprung
98bae4a0a1
Commit
2872f40d13
2 geänderte Dateien mit 30 neuen und 6 gelöschten Zeilen
|
@ -64,14 +64,33 @@ impl Attachment {
|
||||||
|
|
||||||
pub fn delete(self, conn: &DbConn) -> QueryResult<()> {
|
pub fn delete(self, conn: &DbConn) -> QueryResult<()> {
|
||||||
use util;
|
use util;
|
||||||
|
use std::{thread, time};
|
||||||
|
|
||||||
|
let mut retries = 10;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
match diesel::delete(
|
||||||
|
attachments::table.filter(
|
||||||
|
attachments::id.eq(&self.id)
|
||||||
|
)
|
||||||
|
).execute(&**conn) {
|
||||||
|
Ok(_) => break,
|
||||||
|
Err(err) => {
|
||||||
|
if retries < 1 {
|
||||||
|
println!("ERROR: Failed with 10 retries");
|
||||||
|
return Err(err)
|
||||||
|
} else {
|
||||||
|
retries = retries - 1;
|
||||||
|
println!("Had to retry! Retries left: {}", retries);
|
||||||
|
thread::sleep(time::Duration::from_millis(500));
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
util::delete_file(&self.get_file_path());
|
util::delete_file(&self.get_file_path());
|
||||||
|
Ok(())
|
||||||
diesel::delete(
|
|
||||||
attachments::table.filter(
|
|
||||||
attachments::id.eq(self.id)
|
|
||||||
)
|
|
||||||
).execute(&**conn).and(Ok(()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete_all_by_cipher(cipher_uuid: &str, conn: &DbConn) -> QueryResult<()> {
|
pub fn delete_all_by_cipher(cipher_uuid: &str, conn: &DbConn) -> QueryResult<()> {
|
||||||
|
|
|
@ -83,6 +83,11 @@ fn check_db() {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Turn on WAL in SQLite
|
||||||
|
use diesel::RunQueryDsl;
|
||||||
|
let connection = db::get_connection().expect("Can't conect to DB");
|
||||||
|
diesel::sql_query("PRAGMA journal_mode=wal").execute(&connection).expect("Failed to turn on WAL");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_rsa_keys() {
|
fn check_rsa_keys() {
|
||||||
|
|
Laden …
In neuem Issue referenzieren