MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / RenameFile

Method RenameFile

serving/processor/framework/filesystem/oss_file_system.cc:1007–1088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1005}
1006
1007Status OSSFileSystem::RenameFile(const std::string& src,
1008 const std::string& target) {
1009 TF_RETURN_IF_ERROR(oss_initialize());
1010 std::string sobject, sbucket;
1011 std::string host, access_id, access_key;
1012 TF_RETURN_IF_ERROR(
1013 _ParseOSSURIPath(src, sbucket, sobject, host, access_id, access_key));
1014 std::string dobject, dbucket;
1015 std::string dhost, daccess_id, daccess_key;
1016 TF_RETURN_IF_ERROR(_ParseOSSURIPath(target, dbucket, dobject, dhost,
1017 daccess_id, daccess_key));
1018
1019 if (host != dhost || access_id != daccess_id || access_key != daccess_key) {
1020 VLOG(0) << "rename " << src << " to " << target << " failed, with errMsg: "
1021 << " source oss cluster does not match dest oss cluster";
1022 return errors::Internal(
1023 "rename ", src, " to ", target, " failed, errMsg: ",
1024 "source oss cluster does not match dest oss cluster");
1025 }
1026
1027 OSSConnection oss(host, access_id, access_key);
1028 oss_request_options_t* oss_options = oss.getRequestOptions();
1029 aos_pool_t* pool = oss.getPool();
1030
1031 aos_status_t* resp_status;
1032 aos_string_t source_bucket;
1033 aos_string_t source_object;
1034 aos_string_t dest_bucket;
1035 aos_string_t dest_object;
1036
1037 aos_str_set(&source_bucket, sbucket.c_str());
1038 aos_str_set(&dest_bucket, dbucket.c_str());
1039
1040 Status status = IsDirectory(src);
1041 if (status.ok()) {
1042 if (!str_util::EndsWith(sobject, "/")) {
1043 sobject += "/";
1044 }
1045 if (!str_util::EndsWith(dobject, "/")) {
1046 dobject += "/";
1047 }
1048 std::vector<std::string> childPaths;
1049 _ListObjects(pool, oss_options, sbucket, sobject, &childPaths, true, false,
1050 false, 1000);
1051 for (const auto& child : childPaths) {
1052 std::string tmp_sobject = sobject + child;
1053 std::string tmp_dobject = dobject + child;
1054
1055 aos_str_set(&source_object, tmp_sobject.c_str());
1056 aos_str_set(&dest_object, tmp_dobject.c_str());
1057
1058 resp_status =
1059 _RenameFileInternal(oss_options, pool, source_bucket, source_object,
1060 dest_bucket, dest_object);
1061 if (!aos_status_is_ok(resp_status)) {
1062 string msg;
1063 oss_error_message(resp_status, &msg);
1064 VLOG(0) << "rename " << src << " to " << target

Callers

nothing calls this directly

Calls 8

oss_initializeFunction · 0.85
InternalFunction · 0.85
EndsWithFunction · 0.85
oss_error_messageFunction · 0.85
getRequestOptionsMethod · 0.80
getPoolMethod · 0.80
c_strMethod · 0.80
okMethod · 0.45

Tested by

no test coverage detected