mirror of
https://github.com/overte-org/overte.git
synced 2025-08-17 18:10:38 +02:00
protect mapping clobbering when migrating
This commit is contained in:
parent
18b22cbd16
commit
82cd8aed8c
1 changed files with 16 additions and 1 deletions
|
@ -150,6 +150,8 @@ void AssetServer::performMappingMigration() {
|
|||
|
||||
auto files = _resourcesDirectory.entryInfoList(QDir::Files);
|
||||
|
||||
bool addedAtLeastOneMapping = false;
|
||||
|
||||
for (const auto& fileInfo : files) {
|
||||
if (hashFileRegex.exactMatch(fileInfo.fileName())) {
|
||||
// we have a pre-mapping file that we should migrate to the new mapping system
|
||||
|
@ -177,10 +179,23 @@ void AssetServer::performMappingMigration() {
|
|||
auto hash = oldFilename.left(SHA256_HASH_HEX_LENGTH);
|
||||
|
||||
qDebug() << "Adding a migration mapping from" << fakeFileName << "to" << hash;
|
||||
_fileMapping[fakeFileName] = hash;
|
||||
|
||||
auto it = _fileMapping.find(fakeFileName);
|
||||
if (it == _fileMapping.end()) {
|
||||
_fileMapping[fakeFileName] = hash;
|
||||
|
||||
addedAtLeastOneMapping = true;
|
||||
} else {
|
||||
qDebug() << "Could not add migration mapping for" << hash << "since a mapping for" << fakeFileName
|
||||
<< "already exists.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addedAtLeastOneMapping) {
|
||||
// we added at least one new mapping - let's persist changes to file
|
||||
}
|
||||
}
|
||||
|
||||
void AssetServer::handleAssetMappingOperation(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
|
||||
|
|
Loading…
Reference in a new issue