mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added writing of public keyring to a tmp file + rename, to avoid corrupting it when RS stops during the whole operation
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5496 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
32f918c213
commit
f85adfce72
@ -1398,15 +1398,23 @@ bool PGPHandler::locked_syncPublicKeyring()
|
|||||||
// Now check if the pubring was locally modified, which needs saving it again
|
// Now check if the pubring was locally modified, which needs saving it again
|
||||||
if(_pubring_changed)
|
if(_pubring_changed)
|
||||||
{
|
{
|
||||||
|
std::string tmp_keyring_file = _pubring_path + ".tmp" ;
|
||||||
|
|
||||||
std::cerr << "Local changes in public keyring. Writing to disk..." << std::endl;
|
std::cerr << "Local changes in public keyring. Writing to disk..." << std::endl;
|
||||||
if(!ops_write_keyring_to_file(_pubring,ops_false,_pubring_path.c_str(),ops_true))
|
if(!ops_write_keyring_to_file(_pubring,ops_false,tmp_keyring_file.c_str(),ops_true))
|
||||||
std::cerr << "Cannot write public keyring. Disk full? Disk quota exceeded?" << std::endl;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
std::cerr << "Done." << std::endl;
|
std::cerr << "Cannot write public keyring tmp file. Disk full? Disk quota exceeded?" << std::endl;
|
||||||
_pubring_last_update_time = time(NULL) ; // should we get this value from the disk instead??
|
return false ;
|
||||||
_pubring_changed = false ;
|
|
||||||
}
|
}
|
||||||
|
if(!RsDirUtil::renameFile(tmp_keyring_file,_pubring_path))
|
||||||
|
{
|
||||||
|
std::cerr << "Cannot rename tmp pubring file " << tmp_keyring_file << " into actual pubring file " << _pubring_path << ". Check writing permissions?!?" << std::endl;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "Done." << std::endl;
|
||||||
|
_pubring_last_update_time = time(NULL) ; // should we get this value from the disk instead??
|
||||||
|
_pubring_changed = false ;
|
||||||
}
|
}
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user