MCPcopy Create free account
hub / github.com/audacity/audacity / ParseRelease

Method ParseRelease

src/update/UpdateFeedMigrationParser.cpp:38–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36} // namespace
37
38bool UpdateFeedMigrationParser::ParseRelease(const std::string& jsonData, ReleaseInfo &releaseInfo)
39{
40 rapidjson::Document document;
41 document.Parse(jsonData.c_str());
42
43 if (document.HasParseError())
44 {
45 mLastError = std::string("JSON parse error: ") +
46 rapidjson::GetParseError_En(document.GetParseError());
47 wxLogError("UpdateFeedMigrationParser: %s", mLastError);
48 return false;
49 }
50
51 if (!document.IsObject())
52 {
53 mLastError = "Expected JSON object at root";
54 wxLogError("UpdateFeedMigrationParser: %s", mLastError);
55 return false;
56 }
57
58 std::string tagName = GetString(document, "tag_name");
59 releaseInfo.tagName = tagName;
60
61 // Remove 'Audacity-' prefix if present
62 if (tagName.find("Audacity-") == 0)
63 tagName = tagName.substr(9);
64
65 releaseInfo.version = tagName;
66
67 // Parse release notes
68 releaseInfo.notes = GetString(document, "body");
69
70 std::string targetSuffix = GetPlatformFileSuffix();
71 ArchitectureMatch bestMatch = ArchitectureMatch::None;
72
73 if (!document.HasMember("assets") || !document["assets"].IsArray())
74 return false;
75
76 const auto& assets = document["assets"];
77 for (rapidjson::SizeType i = 0; i < assets.Size(); ++i)
78 {
79 if (!assets[i].IsObject())
80 continue;
81
82 const auto& assetObj = assets[i];
83 ReleaseAsset asset;
84 asset.name = GetString(assetObj, "name");
85 asset.downloadUrl = GetString(assetObj, "browser_download_url");
86 asset.arch = GetAssetArchitecture(asset.name);
87
88 releaseInfo.assets.push_back(asset);
89
90 std::string suffix = GetFileSuffix(asset.name);
91 if (suffix == targetSuffix)
92 {
93 ArchitectureMatch match = GetArchitectureMatch(asset.arch);
94 if (match == ArchitectureMatch::None)
95 continue;

Callers 1

FetchReleaseInfoMethod · 0.80

Calls 8

GetStringFunction · 0.85
GetFileSuffixFunction · 0.85
SizeMethod · 0.80
ParseMethod · 0.45
c_strMethod · 0.45
findMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected