From 31345e4264a85bf7e297dd2e91b0f19145762557 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 30 Aug 2017 13:15:14 -0700 Subject: [PATCH 01/10] Fix ATP requests not keeping track of all mapping redirects --- libraries/networking/src/AssetResourceRequest.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/AssetResourceRequest.cpp b/libraries/networking/src/AssetResourceRequest.cpp index c2e0bc1215..c9ca6ebd43 100644 --- a/libraries/networking/src/AssetResourceRequest.cpp +++ b/libraries/networking/src/AssetResourceRequest.cpp @@ -92,10 +92,12 @@ void AssetResourceRequest::requestMappingForPath(const AssetPath& path) { statTracker->incrementStat(STAT_ATP_MAPPING_REQUEST_SUCCESS); // if we got a redirected path we need to store that with the resource request as relative path URL - if (request->wasRedirected() && _failOnRedirect) { + if (request->wasRedirected()) { _relativePathURL = ATP_SCHEME + request->getRedirectedPath(); - _result = RedirectFail; + } + if (request->wasRedirected() && _failOnRedirect) { + _result = RedirectFail; failed = true; } else { requestHash(request->getHash()); From d68338f0b02f19dd747e954413ac8d4957cbd079 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 30 Aug 2017 16:53:31 -0700 Subject: [PATCH 02/10] Add error handling to asset server baking --- assignment-client/src/assets/AssetServer.cpp | 251 +++++++++++++------ assignment-client/src/assets/AssetServer.h | 24 +- 2 files changed, 192 insertions(+), 83 deletions(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index ce9e49326d..b91c8795c2 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -83,6 +83,7 @@ void BakeAssetTask::run() { if (baker->hasErrors()) { qDebug() << "Failed to bake: " << _assetHash << _assetPath; + emit bakeFailed(_assetHash, _assetPath); } else { auto vectorOutputFiles = QVector::fromStdVector(baker->getOutputFiles()); qDebug() << "Finished baking: " << _assetHash << _assetPath << vectorOutputFiles; @@ -99,6 +100,7 @@ void AssetServer::bakeAsset(const AssetHash& assetHash, const AssetPath& assetPa _pendingBakes[assetHash] = task; connect(task.get(), &BakeAssetTask::bakeComplete, this, &AssetServer::handleCompletedBake); + connect(task.get(), &BakeAssetTask::bakeFailed, this, &AssetServer::handleFailedBake); _bakingTaskPool.start(task.get()); } else { @@ -140,7 +142,7 @@ BakingStatus AssetServer::getAssetStatus(const AssetPath& path, const AssetHash& auto bakedPath = "/.baked/" + hash + "/" + bakedFilename; auto jt = _fileMappings.find(bakedPath); if (jt != _fileMappings.end()) { - if (jt->toString() == hash) { + if (jt->first == hash) { return NotBaked; } else { return Baked; @@ -153,8 +155,8 @@ BakingStatus AssetServer::getAssetStatus(const AssetPath& path, const AssetHash& void AssetServer::bakeAssets() { auto it = _fileMappings.cbegin(); for (; it != _fileMappings.cend(); ++it) { - auto path = it.key(); - auto hash = it.value().toString(); + auto path = it->first; + auto hash = it->second; maybeBake(path, hash); } } @@ -181,9 +183,8 @@ void AssetServer::createEmptyMetaFile(const AssetHash& hash) { bool AssetServer::hasMetaFile(const AssetHash& hash) { QString metaFilePath = "/.baked/" + hash + "/meta.json"; - qDebug() << "in mappings?" << metaFilePath; - return _fileMappings.contains(metaFilePath); + return _fileMappings.find(metaFilePath) != _fileMappings.end(); } bool AssetServer::needsToBeBaked(const AssetPath& path, const AssetHash& assetHash) { @@ -200,16 +201,25 @@ bool AssetServer::needsToBeBaked(const AssetPath& path, const AssetHash& assetHa QString bakedFilename; + bool loaded; + AssetMeta meta; + std::tie(loaded, meta) = readMetaFile(assetHash); + + // TODO: Allow failed bakes that happened on old versions to be re-baked + if (loaded && meta.failedLastBake) { + return false; + } + if (BAKEABLE_MODEL_EXTENSIONS.contains(extension)) { bakedFilename = BAKED_MODEL_SIMPLE_NAME; - } else if (BAKEABLE_TEXTURE_EXTENSIONS.contains(extension.toLocal8Bit()) && hasMetaFile(assetHash)) { + } else if (loaded && BAKEABLE_TEXTURE_EXTENSIONS.contains(extension.toLocal8Bit())) { bakedFilename = BAKED_TEXTURE_SIMPLE_NAME; } else { return false; } auto bakedPath = "/.baked/" + assetHash + "/" + bakedFilename; - return !_fileMappings.contains(bakedPath); + return _fileMappings.find(bakedPath) == _fileMappings.end(); } bool interfaceRunning() { @@ -364,7 +374,7 @@ void AssetServer::completeSetup() { qCInfo(asset_server) << "There are" << hashedFiles.size() << "asset files in the asset directory."; - if (_fileMappings.count() > 0) { + if (_fileMappings.size() > 0) { cleanupUnmappedFiles(); } @@ -382,21 +392,26 @@ void AssetServer::cleanupUnmappedFiles() { auto files = _filesDirectory.entryInfoList(QDir::Files); - // grab the currently mapped hashes - auto mappedHashes = _fileMappings.values(); - qCInfo(asset_server) << "Performing unmapped asset cleanup."; for (const auto& fileInfo : files) { - if (hashFileRegex.exactMatch(fileInfo.fileName())) { - if (!mappedHashes.contains(fileInfo.fileName())) { + auto filename = fileInfo.fileName(); + if (hashFileRegex.exactMatch(filename)) { + bool matched { false }; + for (auto& pair : _fileMappings) { + if (pair.second == filename) { + matched = true; + break; + } + } + if (!matched) { // remove the unmapped file QFile removeableFile { fileInfo.absoluteFilePath() }; if (removeableFile.remove()) { - qCDebug(asset_server) << "\tDeleted" << fileInfo.fileName() << "from asset files directory since it is unmapped."; + qCDebug(asset_server) << "\tDeleted" << filename << "from asset files directory since it is unmapped."; } else { - qCDebug(asset_server) << "\tAttempt to delete unmapped file" << fileInfo.fileName() << "failed"; + qCDebug(asset_server) << "\tAttempt to delete unmapped file" << filename << "failed"; } } } @@ -458,9 +473,8 @@ void AssetServer::handleGetMappingOperation(ReceivedMessage& message, SharedNode } else if (BAKEABLE_TEXTURE_EXTENSIONS.contains(assetPathExtension.toLocal8Bit())) { bakedRootFile = BAKED_TEXTURE_SIMPLE_NAME; } - qDebug() << bakedRootFile << assetPathExtension; - auto originalAssetHash = it->toString(); + auto originalAssetHash = it->second; QString redirectedAssetHash; QString bakedAssetPath; quint8 wasRedirected = false; @@ -473,7 +487,7 @@ void AssetServer::handleGetMappingOperation(ReceivedMessage& message, SharedNode if (bakedIt != _fileMappings.end()) { qDebug() << "Did find baked version for: " << originalAssetHash << assetPath; // we found a baked version of the requested asset to serve, redirect to that - redirectedAssetHash = bakedIt->toString(); + redirectedAssetHash = bakedIt->second; wasRedirected = true; } else { qDebug() << "Did not find baked version for: " << originalAssetHash << assetPath; @@ -498,9 +512,8 @@ void AssetServer::handleGetMappingOperation(ReceivedMessage& message, SharedNode auto query = QUrlQuery(url.query()); bool isSkybox = query.hasQueryItem("skybox"); - qDebug() << "Is skybox? " << isSkybox; if (isSkybox) { - createMetaFile(originalAssetHash); + writeMetaFile(originalAssetHash); maybeBake(originalAssetHash, assetPath); } } @@ -512,14 +525,14 @@ void AssetServer::handleGetMappingOperation(ReceivedMessage& message, SharedNode void AssetServer::handleGetAllMappingOperation(ReceivedMessage& message, SharedNodePointer senderNode, NLPacketList& replyPacket) { replyPacket.writePrimitive(AssetServerError::NoError); - auto count = _fileMappings.size(); + uint32_t count = _fileMappings.size(); replyPacket.writePrimitive(count); - for (auto it = _fileMappings.cbegin(); it != _fileMappings.cend(); ++ it) { - replyPacket.writeString(it.key()); - replyPacket.write(QByteArray::fromHex(it.value().toString().toUtf8())); - replyPacket.writePrimitive(getAssetStatus(it.key(), it.value().toString())); + for (auto it = _fileMappings.cbegin(); it != _fileMappings.cend(); ++it) { + replyPacket.writeString(it->first); + replyPacket.write(QByteArray::fromHex(it->second.toUtf8())); + replyPacket.writePrimitive(getAssetStatus(it->first, it->second)); } } @@ -759,31 +772,38 @@ bool AssetServer::loadMappingsFromFile() { auto jsonDocument = QJsonDocument::fromJson(mapFile.readAll(), &error); if (error.error == QJsonParseError::NoError) { - _fileMappings = jsonDocument.object().toVariantHash(); - - // remove any mappings that don't match the expected format - auto it = _fileMappings.begin(); - while (it != _fileMappings.end()) { - bool shouldDrop = false; - - if (!isValidFilePath(it.key())) { - qCWarning(asset_server) << "Will not keep mapping for" << it.key() << "since it is not a valid path."; - shouldDrop = true; - } - - if (!isValidHash(it.value().toString())) { - qCWarning(asset_server) << "Will not keep mapping for" << it.key() << "since it does not have a valid hash."; - shouldDrop = true; - } - - if (shouldDrop) { - it = _fileMappings.erase(it); - } else { - ++it; - } + if (!jsonDocument.isObject()) { + qCWarning(asset_server) << "Failed to read mapping file, root value in" << mapFilePath << "is not an object"; + return false; } - qCInfo(asset_server) << "Loaded" << _fileMappings.count() << "mappings from map file at" << mapFilePath; + //_fileMappings = jsonDocument.object().toVariantHash(); + auto root = jsonDocument.object(); + for (auto it = root.begin(); it != root.end(); ++it) { + auto key = it.key(); + auto value = it.value(); + + if (!value.isString()) { + qCWarning(asset_server) << "Skipping" << key << ":" << value << "because it is not a string"; + continue; + } + + if (!isValidFilePath(key)) { + qCWarning(asset_server) << "Will not keep mapping for" << key << "since it is not a valid path."; + continue; + } + + if (!isValidHash(value.toString())) { + qCWarning(asset_server) << "Will not keep mapping for" << key << "since it does not have a valid hash."; + continue; + } + + + qDebug() << "Added " << key << value.toString(); + _fileMappings[key] = value.toString(); + } + + qCInfo(asset_server) << "Loaded" << _fileMappings.size() << "mappings from map file at" << mapFilePath; return true; } } @@ -802,8 +822,13 @@ bool AssetServer::writeMappingsToFile() { QFile mapFile { mapFilePath }; if (mapFile.open(QIODevice::WriteOnly)) { - auto jsonObject = QJsonObject::fromVariantHash(_fileMappings); - QJsonDocument jsonDocument { jsonObject }; + QJsonObject root; + + for (auto it : _fileMappings) { + root[it.first] = it.second; + } + + QJsonDocument jsonDocument { root }; if (mapFile.write(jsonDocument.toJson()) != -1) { qCDebug(asset_server) << "Wrote JSON mappings to file at" << mapFilePath; @@ -832,7 +857,8 @@ bool AssetServer::setMapping(AssetPath path, AssetHash hash) { } // remember what the old mapping was in case persistence fails - auto oldMapping = _fileMappings.value(path).toString(); + auto it = _fileMappings.find(path); + auto oldMapping = it != _fileMappings.end() ? it->second : ""; // update the in memory QHash _fileMappings[path] = hash; @@ -846,7 +872,7 @@ bool AssetServer::setMapping(AssetPath path, AssetHash hash) { } else { // failed to persist this mapping to file - put back the old one in our in-memory representation if (oldMapping.isEmpty()) { - _fileMappings.remove(path); + _fileMappings.erase(_fileMappings.find(path)); } else { _fileMappings[path] = oldMapping; } @@ -879,9 +905,9 @@ bool AssetServer::deleteMappings(AssetPathList& paths) { auto sizeBefore = _fileMappings.size(); while (it != _fileMappings.end()) { - if (it.key().startsWith(path)) { + if (it->first.startsWith(path)) { // add this hash to the list we need to check for asset removal from the server - hashesToCheckForDeletion << it.value().toString(); + hashesToCheckForDeletion << it->second; it = _fileMappings.erase(it); } else { @@ -897,12 +923,14 @@ bool AssetServer::deleteMappings(AssetPathList& paths) { } } else { - auto oldMapping = _fileMappings.take(path); - if (!oldMapping.isNull()) { - // add this hash to the list we need to check for asset removal from server - hashesToCheckForDeletion << oldMapping.toString(); + auto it = _fileMappings.find(path); + if (it != _fileMappings.end()) { + _fileMappings.erase(it); - qCDebug(asset_server) << "Deleted a mapping:" << path << "=>" << oldMapping.toString(); + // add this hash to the list we need to check for asset removal from server + hashesToCheckForDeletion << it->second; + + qCDebug(asset_server) << "Deleted a mapping:" << path << "=>" << it->second; } else { qCDebug(asset_server) << "Unable to delete a mapping that was not found:" << path; } @@ -913,12 +941,9 @@ bool AssetServer::deleteMappings(AssetPathList& paths) { if (writeMappingsToFile()) { // persistence succeeded we are good to go - // grab the current mapped hashes - auto mappedHashes = _fileMappings.values(); - - // enumerate the mapped hashes and clear the list of hashes to check for anything that's present - for (auto& hashVariant : mappedHashes) { - auto it = hashesToCheckForDeletion.find(hashVariant.toString()); + // TODO iterate through hashesToCheckForDeletion instead + for (auto& pair : _fileMappings) { + auto it = hashesToCheckForDeletion.find(pair.second); if (it != hashesToCheckForDeletion.end()) { hashesToCheckForDeletion.erase(it); } @@ -974,16 +999,17 @@ bool AssetServer::renameMapping(AssetPath oldPath, AssetPath newPath) { auto it = oldMappings.begin(); while (it != oldMappings.end()) { - if (it.key().startsWith(oldPath)) { - auto newKey = it.key(); + auto& oldKey = it->first; + if (oldKey.startsWith(oldPath)) { + auto newKey = oldKey; newKey.replace(0, oldPath.size(), newPath); // remove the old version from the in memory file mappings - _fileMappings.remove(it.key()); - _fileMappings.insert(newKey, it.value()); + _fileMappings.erase(_fileMappings.find(oldKey)); + _fileMappings[newKey] = it->second; } - ++it; + it++; } if (writeMappingsToFile()) { @@ -1008,10 +1034,12 @@ bool AssetServer::renameMapping(AssetPath oldPath, AssetPath newPath) { } // take the old hash to remove the old mapping - auto oldSourceMapping = _fileMappings.take(oldPath).toString(); + auto it = _fileMappings.find(oldPath); + auto oldSourceMapping = it->second; + _fileMappings.erase(it); // in case we're overwriting, keep the current destination mapping for potential rollback - auto oldDestinationMapping = _fileMappings.value(newPath); + auto oldDestinationMapping = _fileMappings.find(newPath)->second; if (!oldSourceMapping.isEmpty()) { _fileMappings[newPath] = oldSourceMapping; @@ -1027,10 +1055,10 @@ bool AssetServer::renameMapping(AssetPath oldPath, AssetPath newPath) { if (!oldDestinationMapping.isNull()) { // put back the overwritten mapping for the destination path - _fileMappings[newPath] = oldDestinationMapping.toString(); + _fileMappings[newPath] = oldDestinationMapping; } else { // clear the new mapping - _fileMappings.remove(newPath); + _fileMappings.erase(_fileMappings.find(newPath)); } qCDebug(asset_server) << "Failed to persist renamed mapping:" << oldPath << "=>" << newPath; @@ -1052,6 +1080,19 @@ QString getBakeMapping(const AssetHash& hash, const QString& relativeFilePath) { return HIDDEN_BAKED_CONTENT_FOLDER + hash + "/" + relativeFilePath; } +void AssetServer::handleFailedBake(QString originalAssetHash, QString assetPath) { + qDebug() << "Failed: " << originalAssetHash << assetPath; + + bool loaded; + AssetMeta meta; + + std::tie(loaded, meta) = readMetaFile(originalAssetHash); + + meta.failedLastBake = true; + + writeMetaFile(originalAssetHash, meta); +} + void AssetServer::handleCompletedBake(QString originalAssetHash, QString originalAssetPath, QVector bakedFilePaths) { bool errorCompletingBake { false }; @@ -1121,20 +1162,68 @@ void AssetServer::handleCompletedBake(QString originalAssetHash, QString origina if (!errorCompletingBake) { // create the meta file to store which version of the baking process we just completed - createMetaFile(originalAssetHash); + writeMetaFile(originalAssetHash); } else { qWarning() << "Could not complete bake for" << originalAssetHash; } } -bool AssetServer::createMetaFile(AssetHash originalAssetHash) { +static const QString BAKE_VERSION_KEY = "bake_version"; +static const QString APP_VERSION_KEY = "app_version"; +static const QString FAILED_LAST_BAKE_KEY = "failed_last_bake"; + +std::pair AssetServer::readMetaFile(AssetHash hash) { + auto metaFilePath = HIDDEN_BAKED_CONTENT_FOLDER + hash + "/" + "meta.json"; + + auto it = _fileMappings.find(metaFilePath); + if (it == _fileMappings.end()) { + return { false, {} }; + } + + auto metaFileHash = it->second; + + QFile metaFile(_filesDirectory.absoluteFilePath(metaFileHash)); + + if (metaFile.open(QIODevice::ReadOnly)) { + auto data = metaFile.readAll(); + metaFile.close(); + + QJsonParseError error; + auto doc = QJsonDocument::fromJson(data, &error); + + if (error.error == QJsonParseError::NoError && doc.isObject()) { + auto root = doc.object(); + + auto bakeVersion = root[BAKE_VERSION_KEY].toInt(-1); + auto appVersion = root[APP_VERSION_KEY].toInt(-1); + auto failedLastBake = root[FAILED_LAST_BAKE_KEY]; + + if (bakeVersion != -1 + && appVersion != -1 + && failedLastBake.isBool()) { + + AssetMeta meta; + meta.bakeVersion = bakeVersion; + meta.applicationVersion = appVersion; + meta.failedLastBake = failedLastBake.toBool(); + + return { true, meta }; + } else { + qCWarning(asset_server) << "Metafile for" << hash << "has either missing or malformed data."; + } + } + } + + return { false, {} }; +} + +bool AssetServer::writeMetaFile(AssetHash originalAssetHash, AssetMeta& meta) { // construct the JSON that will be in the meta file QJsonObject metaFileObject; - static const int BAKE_VERSION = 1; - static const QString VERSION_KEY = "version"; - - metaFileObject[VERSION_KEY] = BAKE_VERSION; + metaFileObject[BAKE_VERSION_KEY] = meta.bakeVersion; + metaFileObject[APP_VERSION_KEY] = meta.applicationVersion; + metaFileObject[FAILED_LAST_BAKE_KEY] = meta.failedLastBake; QJsonDocument metaFileDoc; metaFileDoc.setObject(metaFileObject); @@ -1164,7 +1253,7 @@ bool AssetServer::setBakingEnabled(const AssetPathList& paths, bool enabled) { for (const auto& path : paths) { auto it = _fileMappings.find(path); if (it != _fileMappings.end()) { - auto hash = it->toString(); + auto hash = it->second; auto dotIndex = path.lastIndexOf("."); if (dotIndex == -1) { diff --git a/assignment-client/src/assets/AssetServer.h b/assignment-client/src/assets/AssetServer.h index 94576b329d..f3fff466a3 100644 --- a/assignment-client/src/assets/AssetServer.h +++ b/assignment-client/src/assets/AssetServer.h @@ -22,6 +22,14 @@ #include "AutoBaker.h" #include "ReceivedMessage.h" + +namespace std { + template <> + struct hash { + size_t operator()(const QString& v) const { return qHash(v); } + }; +} + class BakeAssetTask : public QObject, public QRunnable { Q_OBJECT public: @@ -33,6 +41,7 @@ public: signals: void bakeComplete(QString assetHash, QString assetPath, QVector outputFiles); + void bakeFailed(QString assetHash, QString assetPath); private: std::atomic _isBaking { false }; @@ -41,6 +50,15 @@ private: QString _filePath; }; +struct AssetMeta { + AssetMeta() { + } + + int bakeVersion { 0 }; + int applicationVersion { 0 }; + bool failedLastBake { false }; +}; + class AssetServer : public ThreadedAssignment { Q_OBJECT public: @@ -60,7 +78,7 @@ private slots: void sendStatsPacket() override; private: - using Mappings = QVariantHash; + using Mappings = std::unordered_map; void handleGetMappingOperation(ReceivedMessage& message, SharedNodePointer senderNode, NLPacketList& replyPacket); void handleGetAllMappingOperation(ReceivedMessage& message, SharedNodePointer senderNode, NLPacketList& replyPacket); @@ -100,9 +118,11 @@ private: /// Move baked content for asset to baked directory and update baked status void handleCompletedBake(QString originalAssetHash, QString assetPath, QVector bakedFilePaths); + void handleFailedBake(QString originalAssetHash, QString assetPath); /// Create meta file to describe baked content for original asset - bool createMetaFile(AssetHash originalAssetHash); + std::pair readMetaFile(AssetHash hash); + bool writeMetaFile(AssetHash originalAssetHash, AssetMeta& meta = AssetMeta()); Mappings _fileMappings; From 2aa39e7da488dae25f90baac8f2b2e64b9efc0c3 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 30 Aug 2017 16:53:51 -0700 Subject: [PATCH 03/10] Fix baking library not automatically being built --- libraries/baking/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/baking/CMakeLists.txt b/libraries/baking/CMakeLists.txt index 44c52ae0d8..ee2d861539 100644 --- a/libraries/baking/CMakeLists.txt +++ b/libraries/baking/CMakeLists.txt @@ -11,7 +11,5 @@ if (FBX_FOUND) target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${FBX_INCLUDE_DIR}) endif () -set_target_properties(${TARGET_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE EXCLUDE_FROM_DEFAULT_BUILD TRUE) - link_hifi_libraries(shared model networking ktx image) include_hifi_library_headers(gpu) From 9ce0f03aa2b6f3c7f061271cd0022362256894e6 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 31 Aug 2017 11:58:03 -0700 Subject: [PATCH 04/10] Fix mapping comparision in getAssetStatus being done against path --- assignment-client/src/assets/AssetServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index b91c8795c2..5bdaec8d54 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -142,7 +142,7 @@ BakingStatus AssetServer::getAssetStatus(const AssetPath& path, const AssetHash& auto bakedPath = "/.baked/" + hash + "/" + bakedFilename; auto jt = _fileMappings.find(bakedPath); if (jt != _fileMappings.end()) { - if (jt->first == hash) { + if (jt->second == hash) { return NotBaked; } else { return Baked; From d2c7235fed3d1346693cc38c2f4431488bc4fd93 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 31 Aug 2017 14:30:00 -0700 Subject: [PATCH 05/10] Fix update to count width in GetAllMappings --- assignment-client/src/assets/AssetServer.cpp | 2 +- libraries/networking/src/MappingRequest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index 07239fbec4..a4211d4aa8 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -529,7 +529,7 @@ void AssetServer::handleGetMappingOperation(ReceivedMessage& message, SharedNode void AssetServer::handleGetAllMappingOperation(ReceivedMessage& message, SharedNodePointer senderNode, NLPacketList& replyPacket) { replyPacket.writePrimitive(AssetServerError::NoError); - uint32_t count = _fileMappings.size(); + uint32_t count = (uint32_t)_fileMappings.size(); replyPacket.writePrimitive(count); diff --git a/libraries/networking/src/MappingRequest.cpp b/libraries/networking/src/MappingRequest.cpp index 258b7c6359..2d6684ec88 100644 --- a/libraries/networking/src/MappingRequest.cpp +++ b/libraries/networking/src/MappingRequest.cpp @@ -131,7 +131,7 @@ void GetAllMappingsRequest::doStart() { if (!_error) { - int numberOfMappings; + uint32_t numberOfMappings; message->readPrimitive(&numberOfMappings); for (auto i = 0; i < numberOfMappings; ++i) { auto path = message->readString(); From bf53161a0b21dee4d0da0081967f669b63a1ba2c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 31 Aug 2017 15:55:27 -0700 Subject: [PATCH 06/10] Fix comparison between signed and unsigned int in MappingRequest --- libraries/networking/src/MappingRequest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/MappingRequest.cpp b/libraries/networking/src/MappingRequest.cpp index 2d6684ec88..588d8ecc88 100644 --- a/libraries/networking/src/MappingRequest.cpp +++ b/libraries/networking/src/MappingRequest.cpp @@ -133,7 +133,7 @@ void GetAllMappingsRequest::doStart() { if (!_error) { uint32_t numberOfMappings; message->readPrimitive(&numberOfMappings); - for (auto i = 0; i < numberOfMappings; ++i) { + for (uint32_t i = 0; i < numberOfMappings; ++i) { auto path = message->readString(); auto hash = message->read(SHA256_HASH_LENGTH).toHex(); BakingStatus status; From 7a68788c8c9b8646c3fe72f1efa84ac950b693ae Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 31 Aug 2017 16:22:46 -0700 Subject: [PATCH 07/10] Fix warning for non-const default in AssetServer --- assignment-client/src/assets/AssetServer.cpp | 2 +- assignment-client/src/assets/AssetServer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index 5b9cec9346..6653842032 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -1255,7 +1255,7 @@ std::pair AssetServer::readMetaFile(AssetHash hash) { return { false, {} }; } -bool AssetServer::writeMetaFile(AssetHash originalAssetHash, AssetMeta& meta) { +bool AssetServer::writeMetaFile(AssetHash originalAssetHash, const AssetMeta& meta) { // construct the JSON that will be in the meta file QJsonObject metaFileObject; diff --git a/assignment-client/src/assets/AssetServer.h b/assignment-client/src/assets/AssetServer.h index 531c588762..44e16272b2 100644 --- a/assignment-client/src/assets/AssetServer.h +++ b/assignment-client/src/assets/AssetServer.h @@ -122,7 +122,7 @@ private: /// Create meta file to describe baked content for original asset std::pair readMetaFile(AssetHash hash); - bool writeMetaFile(AssetHash originalAssetHash, AssetMeta& meta = AssetMeta()); + bool writeMetaFile(AssetHash originalAssetHash, const AssetMeta& meta = AssetMeta()); /// Remove baked paths when the original asset is deleteds void removeBakedPathsForDeletedAsset(AssetHash originalAssetHash); From 5ee33085a571661a8757bfdfc73275a035be97a5 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 1 Sep 2017 10:37:28 -0700 Subject: [PATCH 08/10] Add handling of failedLastBake error in getAssetStatus --- assignment-client/src/assets/AssetServer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index 6653842032..903322a8ea 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -145,6 +145,14 @@ BakingStatus AssetServer::getAssetStatus(const AssetPath& path, const AssetHash& auto jt = _fileMappings.find(bakedPath); if (jt != _fileMappings.end()) { if (jt->second == hash) { + bool loaded; + AssetMeta meta; + + std::tie(loaded, meta) = readMetaFile(hash); + if (loaded && meta.failedLastBake) { + return Error; + } + return NotBaked; } else { return Baked; From c67fcc13844c9b28e8eb2b304e87aa5f3033e2ae Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 1 Sep 2017 10:41:31 -0700 Subject: [PATCH 09/10] Add RedirectFail to ResourceRequest::getResultString() --- libraries/networking/src/ResourceRequest.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/networking/src/ResourceRequest.cpp b/libraries/networking/src/ResourceRequest.cpp index aeeab2232a..f028535e2f 100644 --- a/libraries/networking/src/ResourceRequest.cpp +++ b/libraries/networking/src/ResourceRequest.cpp @@ -36,6 +36,7 @@ QString ResourceRequest::getResultString() const { case AccessDenied: return "Access Denied"; case InvalidURL: return "Invalid URL"; case NotFound: return "Not Found"; + case RedirectFail: return "Redirect Fail"; default: return "Unspecified Error"; } } From eb2e87a7982897f1612257e5e111bf9f49e3fe0e Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 1 Sep 2017 13:02:25 -0700 Subject: [PATCH 10/10] Change it++ to ++it --- assignment-client/src/assets/AssetServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index 903322a8ea..489e94f3e7 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -1056,7 +1056,7 @@ bool AssetServer::renameMapping(AssetPath oldPath, AssetPath newPath) { _fileMappings[newKey] = it->second; } - it++; + ++it; } if (writeMappingsToFile()) {