MCPcopy Create free account
hub / github.com/78/tenbox / SaveImageMeta

Function SaveImageMeta

src/common/image_source.cpp:180–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180void SaveImageMeta(const std::string& cache_dir, const ImageEntry& entry) {
181 std::error_code ec;
182 fs::create_directories(cache_dir, ec);
183
184 json j;
185 j["id"] = entry.id;
186 j["version"] = entry.version;
187 j["name"] = entry.display_name;
188 j["description"] = entry.description;
189 j["min_app_version"] = entry.min_app_version;
190 j["os"] = entry.os;
191 j["arch"] = entry.arch;
192 j["platform"] = entry.platform.empty() ? "x86_64" : entry.platform;
193
194 json files = json::array();
195 for (const auto& f : entry.files) {
196 json file_j;
197 file_j["name"] = f.name;
198 file_j["url"] = f.url;
199 file_j["sha256"] = f.sha256;
200 file_j["size"] = f.size;
201 files.push_back(file_j);
202 }
203 j["files"] = files;
204
205 fs::path meta_path = fs::path(cache_dir) / "image.json";
206 std::ofstream ofs(meta_path);
207 if (ofs) {
208 ofs << j.dump(2);
209 }
210}
211
212bool LoadImageMeta(const std::string& cache_dir, ImageEntry& entry) {
213 fs::path meta_path = fs::path(cache_dir) / "image.json";

Callers 2

StartImageDownloadMethod · 0.85
StartDownloadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected