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

Method backupCycle

source/game/StarPlayerStorage.cpp:275–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275void PlayerStorage::backupCycle(Uuid const& uuid) {
276 RecursiveMutexLocker locker(m_mutex);
277
278 auto configuration = Root::singleton().configuration();
279 unsigned playerBackupFileCount = configuration->get("playerBackupFileCount").toUInt();
280 auto& fileName = uuidFileName(uuid);
281
282 auto path = [&](String const& dir, String const& extension) {
283 return File::relativeTo(dir, strf("{}.{}", fileName, extension));
284 };
285
286 if (!File::isDirectory(m_backupDirectory))
287 File::makeDirectory(m_backupDirectory);
288
289 File::backupFileInSequence(path(m_storageDirectory, "player"), path(m_backupDirectory, "player"), playerBackupFileCount, ".bak");
290 File::backupFileInSequence(path(m_storageDirectory, "shipworld"), path(m_backupDirectory, "shipworld"), playerBackupFileCount, ".bak");
291 File::backupFileInSequence(path(m_storageDirectory, "metadata"), path(m_backupDirectory, "metadata"), playerBackupFileCount, ".bak");
292}
293
294void PlayerStorage::setMetadata(String key, Json value) {
295 auto& val = m_metadata[std::move(key)];

Callers 1

setMainPlayerMethod · 0.80

Calls 5

singletonClass · 0.85
strfFunction · 0.85
configurationMethod · 0.80
toUIntMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected