File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -492,9 +492,22 @@ impl Collection {
492492 custom_service_error ( "Cannot unlock collection without a secret" )
493493 } ) ?;
494494
495- let unlocked = locked_kr. unlock ( secret) . await . map_err ( |err| {
496- custom_service_error ( & format ! ( "Failed to unlock keyring: {err}" ) )
497- } ) ?;
495+ let keyring_path = locked_kr. path ( ) . map ( |p| p. to_path_buf ( ) ) ;
496+
497+ let unlocked = match locked_kr. unlock ( secret) . await {
498+ Ok ( unlocked) => unlocked,
499+ Err ( err) => {
500+ // Reload the locked keyring from disk before returning error
501+ if let Some ( path) = keyring_path {
502+ if let Ok ( reloaded) = oo7:: file:: LockedKeyring :: load ( & path) . await {
503+ * keyring_guard = Some ( Keyring :: Locked ( reloaded) ) ;
504+ }
505+ }
506+ return Err ( custom_service_error ( & format ! (
507+ "Failed to unlock keyring: {err}"
508+ ) ) ) ;
509+ }
510+ } ;
498511
499512 let items = self . items . lock ( ) . await ;
500513 for item in items. iter ( ) {
You can’t perform that action at this time.
0 commit comments