Skip to content

Commit

Permalink
Collection.create_item: Handle case when service returns a prompt
Browse files Browse the repository at this point in the history
Fixes #39.
  • Loading branch information
mitya57 committed Aug 7, 2022
1 parent 338cbc7 commit bf1e831
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions secretstorage/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,22 @@ def create_item(self, label: str, attributes: Dict[str, str],
SS_PREFIX + 'Item.Label': ('s', label),
SS_PREFIX + 'Item.Attributes': ('a{ss}', attributes),
}
new_item, prompt = self._collection.call('CreateItem', 'a{sv}(oayays)b',
properties, _secret, replace)
return Item(self.connection, new_item, self.session)
item_path, prompt = self._collection.call(
'CreateItem',
'a{sv}(oayays)b',
properties,
_secret,
replace
)
if len(item_path) > 1:
return Item(self.connection, item_path, self.session)
dismissed, result = exec_prompt(self.connection, prompt)
if dismissed:
raise PromptDismissedException('Prompt dismissed.')
signature, item_path = result
assert signature == 'o'
return Item(self.connection, item_path, self.session)


def create_collection(connection: DBusConnection, label: str, alias: str = '',
session: Optional[Session] = None) -> Collection:
Expand Down

0 comments on commit bf1e831

Please sign in to comment.