MCPcopy Create free account
hub / github.com/comaps/comaps / DownloadAsStringFromMeta

Method DownloadAsStringFromMeta

libs/storage/map_files_downloader.cpp:76–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void MapFilesDownloader::DownloadAsStringFromMeta(std::string url, std::function<bool(std::string const &)> && callback,
77 bool forceReset /* = false */)
78{
79 if (m_fileRequest && !forceReset)
80 return;
81
82 Platform & pl = GetPlatform();
83 std::string metaServerUrl = pl.MetaServerUrl();
84 // If user sets a custom download server, skip metaserver entirely.
85 std::string const customServer = pl.CustomMapServerUrl();
86 if (!customServer.empty())
87 {
88 LOG(LINFO, ("Using custom map server URL:", customServer));
89
90 metaServerUrl = customServer;
91 }
92
93 m_fileRequest.reset(RequestT::Get(url::Join(metaServerUrl, url),
94 [this, callback = std::move(callback)](RequestT & request)
95 {
96 bool deleteRequest = true;
97 auto const & buffer = request.GetData();
98
99 LOG(LDEBUG, ("DownloadAsString: status=", request.GetStatus(), "bytes=", buffer.size()));
100
101 // Update deleteRequest flag if new download was requested in callback.
102 deleteRequest = !callback(buffer);
103
104 if (deleteRequest)
105 m_fileRequest.reset();
106 }));
107}
108
109void MapFilesDownloader::DownloadAsString(std::string url, std::function<bool(std::string const &)> && callback,
110 bool forceReset /* = false */)

Callers 1

Calls 8

GetFunction · 0.85
MetaServerUrlMethod · 0.80
JoinFunction · 0.50
emptyMethod · 0.45
resetMethod · 0.45
GetDataMethod · 0.45
GetStatusMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected