| 1392 | } |
| 1393 | |
| 1394 | void UniverseServer::loadTempWorldIndex() { |
| 1395 | auto versioningDatabase = Root::singleton().versioningDatabase(); |
| 1396 | auto storageFile = File::relativeTo(m_storageDirectory, "tempworlds.index"); |
| 1397 | if (File::isFile(storageFile)) { |
| 1398 | try { |
| 1399 | m_tempWorldIndex.clear(); |
| 1400 | auto settings = versioningDatabase->loadVersionedJson(VersionedJson::readFile(storageFile), "TempWorldIndex"); |
| 1401 | for (auto p : settings.iterateObject()) { |
| 1402 | WorldId worldId = parseWorldId(p.first); |
| 1403 | pair<uint64_t, uint64_t> deleteTime = {p.second.get(0).toUInt(), p.second.get(1).toUInt()}; |
| 1404 | m_tempWorldIndex.insert(worldId.get<InstanceWorldId>(), deleteTime); |
| 1405 | } |
| 1406 | } catch (std::exception const& e) { |
| 1407 | Logger::error("UniverseServer: Could not load temp world index file", outputException(e, false)); |
| 1408 | File::rename(storageFile, strf("{}.{}.fail", storageFile, Time::millisecondsSinceEpoch())); |
| 1409 | } |
| 1410 | } |
| 1411 | |
| 1412 | // delete temporary instance worlds not found in the index on load |
| 1413 | auto tempWorldFiles = m_tempWorldIndex.keys().transformed([this](InstanceWorldId const& worldId) { return tempWorldFile(worldId); }); |
| 1414 | for (auto p : File::dirList(m_storageDirectory)) { |
| 1415 | if (p.second == false && p.first.endsWith(".tempworld")) { |
| 1416 | String storageFile = File::relativeTo(m_storageDirectory, p.first); |
| 1417 | if (!tempWorldFiles.contains(storageFile)) { |
| 1418 | Logger::info("UniverseServer: Removing unindexed temporary world {}", p.first); |
| 1419 | File::remove(storageFile); |
| 1420 | } |
| 1421 | } |
| 1422 | } |
| 1423 | } |
| 1424 | |
| 1425 | void UniverseServer::saveTempWorldIndex() { |
| 1426 | JsonObject worldIndex = JsonObject(); |
nothing calls this directly
no test coverage detected