From 4d0976f7306756a9a82806634beae2ed5c444d34 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 11 Apr 2016 08:41:39 -0700 Subject: [PATCH] remove migration code for pre-mapping migrations --- assignment-client/src/assets/AssetServer.cpp | 52 -------------------- assignment-client/src/assets/AssetServer.h | 2 - 2 files changed, 54 deletions(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index 33ae631b77..d9af9f1019 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -134,63 +134,11 @@ void AssetServer::completeSetup() { qInfo() << "There are" << hashedFiles.size() << "asset files in the asset directory."; - performMappingMigration(); - cleanupUnmappedFiles(); nodeList->addNodeTypeToInterestSet(NodeType::Agent); } -void AssetServer::performMappingMigration() { - QRegExp hashFileRegex { "^[a-f0-9]{" + QString::number(SHA256_HASH_HEX_LENGTH) + "}(\\.[\\w]+)+$" }; - - auto files = _resourcesDirectory.entryInfoList(QDir::Files); - - 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 - qDebug() << "Migrating pre-mapping file" << fileInfo.fileName(); - - // rename the file to the same name with no extension - QFile oldFile { fileInfo.absoluteFilePath() }; - - auto oldAbsolutePath = fileInfo.absoluteFilePath(); - auto oldFilename = fileInfo.fileName(); - auto hash = oldFilename.left(SHA256_HASH_HEX_LENGTH); - auto fullExtension = oldFilename.mid(oldFilename.indexOf('.')); - - qDebug() << "\tMoving" << oldAbsolutePath << "to" << oldAbsolutePath.replace(fullExtension, ""); - - bool renamed = oldFile.copy(_filesDirectory.filePath(hash)); - if (!renamed) { - qWarning() << "\tCould not migrate pre-mapping file" << fileInfo.fileName(); - } else { - qDebug() << "\tRenamed pre-mapping file" << fileInfo.fileName(); - - // add a new mapping with the old extension and a truncated version of the hash - const int TRUNCATED_HASH_NUM_CHAR = 16; - auto fakeFileName = "/" + hash.left(TRUNCATED_HASH_NUM_CHAR) + fullExtension; - - qDebug() << "\tAdding a migration mapping from" << fakeFileName << "to" << hash; - - auto it = _fileMappings.find(fakeFileName); - if (it == _fileMappings.end()) { - _fileMappings[fakeFileName] = hash; - - if (writeMappingsToFile()) { - // mapping added and persisted, we can remove the migrated file - oldFile.remove(); - qDebug() << "\tMigration completed for" << oldFilename; - } - } else { - qDebug() << "\tCould not add migration mapping for" << hash << "since a mapping for" << fakeFileName - << "already exists."; - } - } - } - } -} - void AssetServer::cleanupUnmappedFiles() { QRegExp hashFileRegex { "^[a-f0-9]{" + QString::number(SHA256_HASH_HEX_LENGTH) + "}" }; diff --git a/assignment-client/src/assets/AssetServer.h b/assignment-client/src/assets/AssetServer.h index 7e7c3c8b69..a0a85f8fd5 100644 --- a/assignment-client/src/assets/AssetServer.h +++ b/assignment-client/src/assets/AssetServer.h @@ -60,8 +60,6 @@ private: /// Rename mapping from `oldPath` to `newPath`. Returns true if successful bool renameMapping(AssetPath oldPath, AssetPath newPath); - void performMappingMigration(); - // deletes any unmapped files from the local asset directory void cleanupUnmappedFiles();