MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / LoadAppStatsLocalOnly

Function LoadAppStatsLocalOnly

src/common/stats_store.cpp:1166–1188  ·  view source on GitHub ↗

No network; safe under g_mutex. Returns true if local data existed.

Source from the content-addressed store, hash-verified

1164
1165// No network; safe under g_mutex. Returns true if local data existed.
1166static bool LoadAppStatsLocalOnly(uint32_t appId, AppStats& out) {
1167 if (g_diskAccountId == 0) return false; // no account yet; skip disk I/O
1168 std::string path = StatsPath(appId);
1169 bool haveLocal = false;
1170
1171 std::ifstream f(path);
1172 if (f.good()) {
1173 std::string local((std::istreambuf_iterator<char>(f)),
1174 std::istreambuf_iterator<char>());
1175 f.close();
1176 if (!local.empty() && ParseAppStatsJson(local, out))
1177 haveLocal = true;
1178 }
1179 if (haveLocal) {
1180 std::string schemaPath = SchemaPath(appId);
1181 std::ifstream sf(schemaPath, std::ios::binary);
1182 if (sf.good()) {
1183 out.schema.assign(std::istreambuf_iterator<char>(sf),
1184 std::istreambuf_iterator<char>());
1185 }
1186 }
1187 return haveLocal;
1188}
1189
1190// Merge cached cloud blob for one app. Caller holds g_mutex.
1191static bool MergeCloudBlobLocked(uint32_t appId, AppStats& out, bool haveLocal) {

Callers 1

RefreshFromCloudFunction · 0.85

Calls 3

StatsPathFunction · 0.85
ParseAppStatsJsonFunction · 0.85
SchemaPathFunction · 0.85

Tested by

no test coverage detected