1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-06-15 15:20:07 +00:00

Improve Folder::delete() to handle FolderCipher

This commit is contained in:
Miroslav Prasil 2018-05-16 17:19:52 +01:00
parent 795d98afa6
commit e54b52f109
4 changed files with 30 additions and 15 deletions

View file

@ -81,13 +81,14 @@ impl Folder {
}
}
pub fn delete(self, conn: &DbConn) -> bool {
match diesel::delete(folders::table.filter(
folders::uuid.eq(self.uuid)))
.execute(&**conn) {
Ok(1) => true, // One row deleted
_ => false,
}
pub fn delete(self, conn: &DbConn) -> QueryResult<()> {
FolderCipher::delete_all_by_folder(&self.uuid, &conn)?;
diesel::delete(
folders::table.filter(
folders::uuid.eq(self.uuid)
)
).execute(&**conn).and(Ok(()))
}
pub fn find_by_uuid(uuid: &str, conn: &DbConn) -> Option<Self> {
@ -123,6 +124,12 @@ impl FolderCipher {
).execute(&**conn).and(Ok(()))
}
pub fn delete_all_by_folder(folder_uuid: &str, conn: &DbConn) -> QueryResult<()> {
diesel::delete(folders_ciphers::table
.filter(folders_ciphers::folder_uuid.eq(folder_uuid))
).execute(&**conn).and(Ok(()))
}
pub fn find_by_folder_and_cipher(folder_uuid: &str, cipher_uuid: &str, conn: &DbConn) -> Option<Self> {
folders_ciphers::table
.filter(folders_ciphers::folder_uuid.eq(folder_uuid))