MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / loadTempWorldIndex

Method loadTempWorldIndex

source/game/StarUniverseServer.cpp:1394–1423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1392}
1393
1394void 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
1425void UniverseServer::saveTempWorldIndex() {
1426 JsonObject worldIndex = JsonObject();

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
parseWorldIdFunction · 0.85
errorFunction · 0.85
strfFunction · 0.85
versioningDatabaseMethod · 0.80
iterateObjectMethod · 0.80
toUIntMethod · 0.80
outputExceptionFunction · 0.50
clearMethod · 0.45
loadVersionedJsonMethod · 0.45
getMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected