Skip to content

Commit fe2168f

Browse files
cli: Fix item check for locked ones
As the server doesn't really return a IsLocked error
1 parent 84c7f97 commit fe2168f

1 file changed

Lines changed: 8 additions & 27 deletions

File tree

cli/src/main.rs

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -195,37 +195,18 @@ impl ItemOutput {
195195
}
196196

197197
async fn from_dbus_item(item: &oo7::dbus::Item, as_hex: bool) -> Result<Self, Error> {
198-
use oo7::dbus::ServiceError;
199-
200198
let is_locked = item.is_locked().await?;
201-
let secret = match item.secret().await {
202-
Ok(secret) => Ok(Some(secret)),
203-
Err(oo7::dbus::Error::Service(ServiceError::IsLocked(_))) => Ok(None),
204-
Err(e) => Err(e),
205-
}?;
206-
let attributes = match item.attributes().await {
207-
Ok(attributes) => Ok(Some(attributes)),
208-
Err(oo7::dbus::Error::Service(ServiceError::IsLocked(_))) => Ok(None),
209-
Err(e) => Err(e),
210-
}?;
211-
let created = match item.created().await {
212-
Ok(created) => Ok(Some(created)),
213-
Err(oo7::dbus::Error::Service(ServiceError::IsLocked(_))) => Ok(None),
214-
Err(e) => Err(e),
215-
}?;
216-
let modified = match item.modified().await {
217-
Ok(modified) => Ok(Some(modified)),
218-
Err(oo7::dbus::Error::Service(ServiceError::IsLocked(_))) => Ok(None),
219-
Err(e) => Err(e),
220-
}?;
199+
if is_locked {
200+
return Ok(Self::new(None, "(locked)", None, None, None, true, as_hex));
201+
}
221202

222203
Ok(Self::new(
223-
secret.as_ref(),
204+
Some(&item.secret().await?),
224205
&item.label().await?,
225-
attributes,
226-
created,
227-
modified,
228-
is_locked,
206+
Some(item.attributes().await?),
207+
Some(item.created().await?),
208+
Some(item.modified().await?),
209+
false,
229210
as_hex,
230211
))
231212
}

0 commit comments

Comments
 (0)