Skip to content

Commit

Permalink
Use is_running function
Browse files Browse the repository at this point in the history
  • Loading branch information
quexten committed Dec 9, 2024
1 parent 5f38355 commit 39fbb48
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions apps/desktop/desktop_native/core/src/ssh_agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct SshAgentUIRequest {

impl ssh_agent::Agent<peerinfo::models::PeerInfo> for BitwardenDesktopAgent {
async fn confirm(&self, ssh_key: Key, info: &peerinfo::models::PeerInfo) -> bool {
if self.is_running.load(std::sync::atomic::Ordering::Relaxed) {
if self.is_running() {
println!("[BitwardenDesktopAgent] Agent is not running, but tried to call confirm");
return false;
}
Expand Down Expand Up @@ -92,7 +92,7 @@ impl ssh_agent::Agent<peerinfo::models::PeerInfo> for BitwardenDesktopAgent {

impl BitwardenDesktopAgent {
pub fn stop(&self) {
if self.is_running.load(std::sync::atomic::Ordering::Relaxed) {
if self.is_running() {
println!("[BitwardenDesktopAgent] Tried to stop agent while it is not running");
return;
}
Expand All @@ -109,7 +109,7 @@ impl BitwardenDesktopAgent {
&mut self,
new_keys: Vec<(String, String, String)>,
) -> Result<(), anyhow::Error> {
if self.is_running.load(std::sync::atomic::Ordering::Relaxed) {
if self.is_running() {
return Err(anyhow::anyhow!(
"[BitwardenDesktopAgent] Tried to set keys while agent is not running"
));
Expand Down Expand Up @@ -146,7 +146,7 @@ impl BitwardenDesktopAgent {
}

pub fn lock(&mut self) -> Result<(), anyhow::Error> {
if self.is_running.load(std::sync::atomic::Ordering::Relaxed) {
if self.is_running() {
return Err(anyhow::anyhow!(
"[BitwardenDesktopAgent] Tried to lock agent, but it is not running"
));
Expand All @@ -173,7 +173,7 @@ impl BitwardenDesktopAgent {
}

async fn get_request_id(&self) -> u32 {
if self.is_running.load(std::sync::atomic::Ordering::Relaxed) {
if self.is_running() {
println!("[BitwardenDesktopAgent] Agent is not running, but tried to get request id");
return 0;
}
Expand All @@ -182,7 +182,7 @@ impl BitwardenDesktopAgent {
request_id
}

pub fn is_running(self) -> bool {
pub fn is_running(&self) -> bool {
self.is_running.load(std::sync::atomic::Ordering::Relaxed)
}
}
Expand Down

0 comments on commit 39fbb48

Please sign in to comment.