| 273 | } |
| 274 | |
| 275 | void 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 | |
| 294 | void PlayerStorage::setMetadata(String key, Json value) { |
| 295 | auto& val = m_metadata[std::move(key)]; |
no test coverage detected