improved error handling, and ensures that keyring is always kept consistent

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6395 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-05-31 19:16:04 +00:00
parent 4b21232beb
commit e11f60150c
5 changed files with 32 additions and 13 deletions

View file

@ -1610,6 +1610,13 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::list<PGPIdType>& keys_to_re
continue ;
}
if(res->second._key_index >= _pubring->nkeys || PGPIdType(_pubring->keys[res->second._key_index].key_id) != *it)
{
std::cerr << "(EE) PGPHandler:: can't remove key " << (*it).toStdString() << ". Inconsistency found." << std::endl;
error_code = PGP_KEYRING_REMOVAL_ERROR_DATA_INCONSISTENCY ;
return false ;
}
// Move the last key to the freed place. This deletes the key in place.
//
ops_keyring_remove_key(_pubring,res->second._key_index) ;
@ -1631,13 +1638,6 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::list<PGPIdType>& keys_to_re
}
}
if(_public_keyring_map.size() != _pubring->nkeys)
{
std::cerr << "Error after removing keys. Operation cancelled." << std::endl;
// todo
}
// Everything went well, sync back the keyring on disk
_pubring_changed = true ;