mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 04:08:13 +02:00
CR
This commit is contained in:
parent
87f77b6257
commit
46449256ce
3 changed files with 20 additions and 18 deletions
|
@ -41,8 +41,12 @@ void UploadAssetTask::run() {
|
||||||
|
|
||||||
uint64_t fileSize;
|
uint64_t fileSize;
|
||||||
buffer.read(reinterpret_cast<char*>(&fileSize), sizeof(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);
|
auto replyPacket = NLPacket::create(PacketType::AssetUploadReply, -1, true);
|
||||||
replyPacket->writePrimitive(messageID);
|
replyPacket->writePrimitive(messageID);
|
||||||
|
@ -54,8 +58,12 @@ void UploadAssetTask::run() {
|
||||||
|
|
||||||
auto hash = AssetUtils::hashData(fileData);
|
auto hash = AssetUtils::hashData(fileData);
|
||||||
auto hexHash = hash.toHex();
|
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)) };
|
QFile file { _resourcesDir.filePath(QString(hexHash)) };
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// BackupSupervisor.cpp
|
// BackupSupervisor.cpp
|
||||||
// assignment-client/src
|
// domain-server/src
|
||||||
//
|
//
|
||||||
// Created by Clement Brisset on 1/12/18.
|
// Created by Clement Brisset on 1/12/18.
|
||||||
// Copyright 2018 High Fidelity, Inc.
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
@ -106,28 +106,22 @@ bool BackupSupervisor::loadBackup(const QString& backupFile) {
|
||||||
}
|
}
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
auto document = QJsonDocument::fromJson(file.readAll(), &error);
|
auto document = QJsonDocument::fromJson(file.readAll(), &error);
|
||||||
if (document.isNull()) {
|
if (document.isNull() || !document.isObject()) {
|
||||||
qCritical() << "Could not parse backup file:" << backupFile;
|
qCritical() << "Could not parse backup file to JSON object:" << backupFile;
|
||||||
qCritical() << " Error:" << error.errorString();
|
|
||||||
backup.corruptedBackup = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!document.isObject()) {
|
|
||||||
qCritical() << "Backup file corrupted" << backupFile;
|
|
||||||
backup.corruptedBackup = true;
|
backup.corruptedBackup = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto jsonObject = document.object();
|
auto jsonObject = document.object();
|
||||||
for (auto it = begin(jsonObject); it != end(jsonObject); ++it) {
|
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();
|
qCritical() << "Corrupted mapping in backup file" << backupFile << ":" << it.key();
|
||||||
backup.corruptedBackup = true;
|
backup.corruptedBackup = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto& assetPath = it.key();
|
|
||||||
const auto& assetHash = it.value().toString();
|
|
||||||
|
|
||||||
backup.mappings[assetPath] = assetHash;
|
backup.mappings[assetPath] = assetHash;
|
||||||
_assetsInBackups.insert(assetHash);
|
_assetsInBackups.insert(assetHash);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// BackupSupervisor.h
|
// BackupSupervisor.h
|
||||||
// assignment-client/src
|
// domain-server/src
|
||||||
//
|
//
|
||||||
// Created by Clement Brisset on 1/12/18.
|
// Created by Clement Brisset on 1/12/18.
|
||||||
// Copyright 2018 High Fidelity, Inc.
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
|
Loading…
Reference in a new issue