!2230 修改errno处理

Merge pull request !2230 from xuqian0131/errno
This commit is contained in:
openharmony_ci 2024-11-04 10:09:18 +00:00 committed by Gitee
commit a48daf186b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 6 additions and 2 deletions

View File

@ -83,6 +83,7 @@ IInnerOsAccountManager::IInnerOsAccountManager() : subscribeManager_(OsAccountSu
osAccountControl_->GetDeviceOwnerId(deviceOwnerId_);
osAccountControl_->GetDefaultActivatedOsAccount(defaultActivatedId_);
osAccountControl_->GetOsAccountConfig(config_);
SetParameter(PARAM_LOGIN_NAME_MAX.c_str(), std::to_string(Constants::LOCAL_NAME_MAX_SIZE).c_str());
ACCOUNT_LOGI("Init end, maxOsAccountNum: %{public}d, maxLoggedInOsAccountNum: %{public}d",
config_.maxOsAccountNum, config_.maxLoggedInOsAccountNum);
}
@ -1025,7 +1026,6 @@ void IInnerOsAccountManager::Init()
ACCOUNT_LOGI("Start to create base os accounts");
CreateBaseAdminAccount();
CreateBaseStandardAccount();
SetParameter(PARAM_LOGIN_NAME_MAX.c_str(), std::to_string(Constants::LOCAL_NAME_MAX_SIZE).c_str());
ACCOUNT_LOGI("End to create base os accounts");
}

View File

@ -531,13 +531,17 @@ ErrCode OsAccountControlFileManager::GetOsAccountInfoById(const int id, OsAccoun
{
std::string path = Constants::USER_INFO_BASE + Constants::PATH_SEPARATOR + std::to_string(id) +
Constants::PATH_SEPARATOR + Constants::USER_INFO_FILE_NAME;
ErrCode err = ERR_ACCOUNT_COMMON_FILE_READ_FAILED;
if (!accountFileOperator_->IsExistFile(path)) {
if (errno == ENOENT) {
err = ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR;
}
ACCOUNT_LOGE("file %{public}s does not exist err", path.c_str());
if (GetOsAccountFromDatabase("", id, osAccountInfo) == ERR_OK) {
InsertOsAccount(osAccountInfo);
return ERR_OK;
}
return errno == ENOENT ? ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR : ERR_ACCOUNT_COMMON_FILE_READ_FAILED;
return err;
}
std::string accountInfoStr;
if (accountFileOperator_->GetFileContentByPath(path, accountInfoStr) != ERR_OK) {