Skip to content

Commit

Permalink
Added unlock_all method
Browse files Browse the repository at this point in the history
  • Loading branch information
nikarh authored and complexspaces committed Jun 6, 2024
1 parent 3e8e7c5 commit 762ff80
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/blocking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
//! [zbus's blocking documentation]: https://docs.rs/zbus/latest/zbus/blocking/index.html
//! [async `SecretService`]: crate::SecretService

use crate::proxy::service::ServiceProxyBlocking;
use crate::session::Session;
use crate::ss::SS_COLLECTION_LABEL;
use crate::util;
use crate::{proxy::service::ServiceProxyBlocking, util::exec_prompt_blocking};
use crate::{EncryptionType, Error, SearchItemsResult};
use std::collections::HashMap;
use zbus::zvariant::{ObjectPath, Value};
Expand Down Expand Up @@ -178,6 +178,18 @@ impl<'a> SecretService<'a> {
locked: object_paths_to_items(items.locked)?,
})
}

/// Unlock all items in a batch
pub fn unlock_all(&self, items: &[&Item<'_>]) -> Result<(), Error> {
let objects = items.iter().map(|i| &*i.item_path).collect();
let lock_action_res = self.service_proxy.unlock(objects)?;

if lock_action_res.object_paths.is_empty() {
exec_prompt_blocking(self.conn.clone(), &lock_action_res.prompt)?;
}

Ok(())
}
}

#[cfg(test)]
Expand Down
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,18 @@ impl<'a> SecretService<'a> {
.collect::<Result<_, _>>()?,
})
}

/// Unlock all items in a batch
pub async fn unlock_all(&self, items: &[&Item<'_>]) -> Result<(), Error> {
let objects = items.iter().map(|i| &*i.item_path).collect();
let lock_action_res = self.service_proxy.unlock(objects).await?;

if lock_action_res.object_paths.is_empty() {
exec_prompt(self.conn.clone(), &lock_action_res.prompt).await?;
}

Ok(())
}
}

#[cfg(test)]
Expand Down

0 comments on commit 762ff80

Please sign in to comment.