!311 merge modified_warn_0115 into master

修改铃音库文件路径检查警告

Created-by: neusoft_group_co_ltd_cc
Commit-by: caochuan
Merged-by: openharmony_ci
Description: ### 一、内容说明(相关的Issue)



### 二、建议测试周期和提测地址  
  建议测试完成时间:xxxx.xx.xx  
  投产上线时间:xxxx.xx.xx  
  提测地址:CI环境/压测环境  
  测试账号:  

### 三、变更内容
  * 3.1 关联PR列表

  * 3.2 数据库和部署说明  
    1. 常规更新 
    2. 重启unicorn
    3. 重启sidekiq
    4. 迁移任务:是否有迁移任务,没有写 "无"
    5. rake脚本:`bundle exec xxx RAILS_ENV = production`;没有写 "无"

  * 3.4 其他技术优化内容(做了什么,变更了什么)
    - 重构了 xxxx 代码
    - xxxx 算法优化


  * 3.5 废弃通知(什么字段、方法弃用?)



  * 3.6  后向不兼容变更(是否有无法向后兼容的变更?)


  
### 四、研发自测点(自测哪些?冒烟用例全部自测?)
  自测测试结论:


### 五、测试关注点(需要提醒QA重点关注的、可能会忽略的地方)
  检查点:

| 需求名称 | 是否影响xx公共模块 | 是否需要xx功能 | 需求升级是否依赖其他子产品 |
|------|------------|----------|---------------|
| xxx  | 否          | 需要       | 不需要           |
|      |            |          |               |

  接口测试:

  性能测试:

  并发测试:

  其他:



See merge request: openharmony/multimedia_ringtone_library!311
This commit is contained in:
openharmony_ci
2026-01-29 14:12:15 +08:00
+21 -3
View File
@@ -489,9 +489,27 @@ bool RingtoneFileUtils::CopyFileUtil(const string &filePath, const string &newPa
int32_t RingtoneFileUtils::CopyFileFromFd(int32_t srcFd, const std::string &newPath)
{
CHECK_AND_RETURN_RET_LOG(!RingtoneFileUtils::IsFileExists(newPath), E_HAS_FS_ERROR,
"error file exists:%{public}s", newPath.c_str());
int32_t dest = open(newPath.c_str(), O_WRONLY | O_CREAT, MODE_RW_USR);
CHECK_AND_RETURN_RET_LOG(!newPath.empty(), E_HAS_FS_ERROR,
"file path is empty:%{private}s", newPath.c_str());
std::string filename;
std::string dirPath;
size_t lastSlash = newPath.find_last_of('/');
if (lastSlash != std::string::npos) {
dirPath = newPath.substr(0, lastSlash);
filename = newPath.substr(lastSlash + 1);
} else {
RINGTONE_ERR_LOG("file path is error:%{private}s", newPath.c_str());
return E_HAS_FS_ERROR;
}
char filePathTemp[PATH_MAX] = {0};
bool bflag = realpath(dirPath.c_str(), filePathTemp) == nullptr;
CHECK_AND_RETURN_RET_LOG(!bflag, E_ERR,
"check newPath fail, dirPath = %{private}s", dirPath.c_str());
std::string path = std::string(filePathTemp) + "/" + filename;
CHECK_AND_RETURN_RET_LOG(!RingtoneFileUtils::IsFileExists(path), E_HAS_FS_ERROR,
"error file exists:%{private}s", path.c_str());
int32_t dest = open(path.c_str(), O_WRONLY | O_CREAT, MODE_RW_USR);
CHECK_AND_RETURN_RET_LOG(dest > 0, E_ERR, "Open failed for destination file %{public}d", errno);
OHOS::UniqueFd destFd(dest);