No network; safe under g_mutex. Returns true if local data existed.
| 1164 | |
| 1165 | // No network; safe under g_mutex. Returns true if local data existed. |
| 1166 | static 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. |
| 1191 | static bool MergeCloudBlobLocked(uint32_t appId, AppStats& out, bool haveLocal) { |
no test coverage detected