fixed bug when retroshare-service -U list is ran with no account

This commit is contained in:
csoler 2021-02-20 09:32:57 +01:00
parent d1baa3821a
commit 481a207ccb
2 changed files with 15 additions and 9 deletions

View File

@ -155,10 +155,11 @@ class RsInit
public:
enum RS_DEPRECATED_FOR(RsInitErrorNum) LoadCertificateStatus : uint8_t
{
OK, /// Everything go as expected, no error occurred
ERR_ALREADY_RUNNING, /// Another istance is running already
ERR_CANT_ACQUIRE_LOCK, /// Another istance is already running?
ERR_UNKNOWN /// Unkown error, maybe password is wrong?
OK, /// Everything go as expected, no error occurred
ERR_ALREADY_RUNNING, /// Another istance is running already
ERR_CANT_ACQUIRE_LOCK, /// Another istance is already running?
ERR_NO_AVAILABLE_ACCOUNT, /// Used in retroshare-service -U list when no account is available
ERR_UNKNOWN /// Unkown error, maybe password is wrong?
};
/* reorganised RsInit system */

View File

@ -234,14 +234,19 @@ int main(int argc, char* argv[])
{
if(prefUserString == "list")
{
std::cout << std::endl << std::endl
<< "Available accounts:" << std::endl;
std::vector<RsLoginHelper::Location> locations;
rsLoginHelper->getLocations(locations);
int accountCountDigits = static_cast<int>(
ceil(log(locations.size())/log(10.0)) );
if(locations.size() == 0)
{
RsErr() << "No available accounts. You cannot use option -U list" << std::endl;
return -RsInit::ERR_NO_AVAILABLE_ACCOUNT;
}
std::cout << std::endl << std::endl
<< "Available accounts:" << std::endl;
int accountCountDigits = static_cast<int>( ceil(log(locations.size())/log(10.0)) );
for( uint32_t i=0; i<locations.size(); ++i )
std::cout << "[" << std::setw(accountCountDigits)