This commit is contained in:
Atlante45 2018-02-09 11:32:54 -08:00
parent 87f77b6257
commit 46449256ce
3 changed files with 20 additions and 18 deletions

View file

@ -41,8 +41,12 @@ void UploadAssetTask::run() {
uint64_t fileSize;
buffer.read(reinterpret_cast<char*>(&fileSize), sizeof(fileSize));
qDebug() << "UploadAssetTask reading a file of " << fileSize << "bytes.";
if (_senderNode) {
qDebug() << "UploadAssetTask reading a file of " << fileSize << "bytes from" << uuidStringWithoutCurlyBraces(_senderNode->getUUID());
} else {
qDebug() << "UploadAssetTask reading a file of " << fileSize << "bytes from" << _receivedMessage->getSenderSockAddr();
}
auto replyPacket = NLPacket::create(PacketType::AssetUploadReply, -1, true);
replyPacket->writePrimitive(messageID);
@ -54,8 +58,12 @@ void UploadAssetTask::run() {
auto hash = AssetUtils::hashData(fileData);
auto hexHash = hash.toHex();
qDebug() << "Hash for uploaded file is: (" << hexHash << ") ";
if (_senderNode) {
qDebug() << "Hash for uploaded file from" << uuidStringWithoutCurlyBraces(_senderNode->getUUID()) << "is: (" << hexHash << ")";
} else {
qDebug() << "Hash for uploaded file from" << _receivedMessage->getSenderSockAddr() << "is: (" << hexHash << ")";
}
QFile file { _resourcesDir.filePath(QString(hexHash)) };

View file

@ -1,6 +1,6 @@
//
// BackupSupervisor.cpp
// assignment-client/src
// domain-server/src
//
// Created by Clement Brisset on 1/12/18.
// Copyright 2018 High Fidelity, Inc.
@ -106,28 +106,22 @@ bool BackupSupervisor::loadBackup(const QString& backupFile) {
}
QJsonParseError error;
auto document = QJsonDocument::fromJson(file.readAll(), &error);
if (document.isNull()) {
qCritical() << "Could not parse backup file:" << backupFile;
qCritical() << " Error:" << error.errorString();
backup.corruptedBackup = true;
return false;
}
if (!document.isObject()) {
qCritical() << "Backup file corrupted" << backupFile;
if (document.isNull() || !document.isObject()) {
qCritical() << "Could not parse backup file to JSON object:" << backupFile;
backup.corruptedBackup = true;
return false;
}
auto jsonObject = document.object();
for (auto it = begin(jsonObject); it != end(jsonObject); ++it) {
if (!it.value().isString()) {
const auto& assetPath = it.key();
const auto& assetHash = it.value().toString();
if (!AssetUtils::isValidHash(assetHash)) {
qCritical() << "Corrupted mapping in backup file" << backupFile << ":" << it.key();
backup.corruptedBackup = true;
return false;
}
const auto& assetPath = it.key();
const auto& assetHash = it.value().toString();
backup.mappings[assetPath] = assetHash;
_assetsInBackups.insert(assetHash);

View file

@ -1,6 +1,6 @@
//
// BackupSupervisor.h
// assignment-client/src
// domain-server/src
//
// Created by Clement Brisset on 1/12/18.
// Copyright 2018 High Fidelity, Inc.