From 8452289e00ad73f1727eefda90bd13af49bc2b0d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 27 Aug 2015 15:56:07 -0700 Subject: [PATCH] Fix issue with raw hash not being converted to hex --- assignment-client/src/assets/AssetServer.cpp | 4 +++- assignment-client/src/assets/SendAssetTask.cpp | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index c1457db55b..0308042391 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -101,10 +101,12 @@ void AssetServer::handleAssetGetInfo(QSharedPointer packet, SharedNode auto replyPacket = NLPacket::create(PacketType::AssetGetInfoReply); + QByteArray hexHash = assetHash.toHex(); + replyPacket->writePrimitive(messageID); replyPacket->write(assetHash); - QString fileName = QString(assetHash) + "." + extension; + QString fileName = QString(hexHash) + "." + extension; QFileInfo fileInfo { _resourcesDirectory.filePath(fileName) }; if (fileInfo.exists() && fileInfo.isReadable()) { diff --git a/assignment-client/src/assets/SendAssetTask.cpp b/assignment-client/src/assets/SendAssetTask.cpp index 7099d69988..e80195c1b6 100644 --- a/assignment-client/src/assets/SendAssetTask.cpp +++ b/assignment-client/src/assets/SendAssetTask.cpp @@ -34,7 +34,8 @@ SendAssetTask::SendAssetTask(MessageID messageID, const QByteArray& assetHash, Q } void SendAssetTask::run() { - qDebug() << "Starting task to send asset: " << _assetHash << " for messageID " << _messageID; + QString assetHashHex = _assetHash.toHex(); + qDebug() << "Starting task to send asset: " << assetHashHex << " for messageID " << _messageID; auto replyPacketList = std::unique_ptr(new NLPacketList(PacketType::AssetGetReply, QByteArray(), true, true)); replyPacketList->write(_assetHash); @@ -49,18 +50,18 @@ void SendAssetTask::run() { if (file.open(QIODevice::ReadOnly)) { if (file.size() < _end) { writeError(replyPacketList.get(), AssetServerError::INVALID_BYTE_RANGE); - qCDebug(networking) << "Bad byte range: " << _assetHash.toHex() << " " << _start << ":" << _end; + qCDebug(networking) << "Bad byte range: " << assetHashHex << " " << _start << ":" << _end; } else { auto size = _end - _start; file.seek(_start); replyPacketList->writePrimitive(AssetServerError::NO_ERROR); replyPacketList->writePrimitive(size); replyPacketList->write(file.read(size)); - qCDebug(networking) << "Sending asset: " << _assetHash.toHex(); + qCDebug(networking) << "Sending asset: " << assetHashHex; } file.close(); } else { - qCDebug(networking) << "Asset not found: " << _filePath << "(" << _assetHash << ")"; + qCDebug(networking) << "Asset not found: " << _filePath << "(" << assetHashHex << ")"; writeError(replyPacketList.get(), AssetServerError::ASSET_NOT_FOUND); } }