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

Method _ListObjects

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

For GetChildren , we should not return prefix

Source from the content-addressed store, hash-verified

624
625// For GetChildren , we should not return prefix
626Status OSSFileSystem::_ListObjects(
627 aos_pool_t* pool, const oss_request_options_t* options,
628 const std::string& bucket, const std::string& key,
629 std::vector<std::string>* result, bool return_all, bool return_full_path,
630 bool should_remove_suffix, int max_ret_per_iterator) {
631 aos_string_t bucket_;
632 aos_status_t* s = NULL;
633 oss_list_object_params_t* params = NULL;
634 oss_list_object_content_t* content = NULL;
635 const char* next_marker = "";
636
637 aos_str_set(&bucket_, bucket.c_str());
638 params = oss_create_list_object_params(pool);
639 params->max_ret = max_ret_per_iterator;
640 aos_str_set(&params->prefix, key.c_str());
641 aos_str_set(&params->marker, next_marker);
642
643 do {
644 s = oss_list_object(options, &bucket_, params, NULL);
645 if (!aos_status_is_ok(s)) {
646 string msg;
647 oss_error_message(s, &msg);
648 VLOG(0) << "can not list object " << key << " errMsg: " << msg;
649 return errors::NotFound("can not list object:", key, " errMsg: ", msg);
650 }
651
652 aos_list_for_each_entry(oss_list_object_content_t, content,
653 &params->object_list, node) {
654 int path_length = content->key.len;
655 if (should_remove_suffix && path_length > 0 &&
656 content->key.data[content->key.len - 1] == '/') {
657 path_length = content->key.len - 1;
658 }
659 if (return_full_path) {
660 string child(content->key.data, 0, path_length);
661 result->push_back(child);
662 } else {
663 int prefix_len = (key.length() > 0 && key.at(key.length() - 1) != '/')
664 ? key.length() + 1
665 : key.length();
666 // remove prefix for GetChildren
667 if (content->key.len > prefix_len) {
668 string child(content->key.data + prefix_len, 0,
669 path_length - prefix_len);
670 result->push_back(child);
671 }
672 }
673 }
674
675 next_marker = apr_psprintf(pool, "%.*s", params->next_marker.len,
676 params->next_marker.data);
677
678 aos_str_set(&params->marker, next_marker);
679 aos_list_init(&params->object_list);
680 aos_list_init(&params->common_prefix_list);
681 } while (params->truncated == AOS_TRUE && return_all);
682
683 return Status::OK();

Callers

nothing calls this directly

Calls 6

oss_error_messageFunction · 0.85
NotFoundFunction · 0.85
c_strMethod · 0.80
push_backMethod · 0.45
lengthMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected