Fix replacement octree data not working

This commit is contained in:
Ryan Huffman 2018-02-14 11:38:18 -08:00 committed by Atlante45
parent 2a667fcd60
commit 0bbbff95cd
3 changed files with 17 additions and 15 deletions

View file

@ -176,8 +176,6 @@ protected:
UniqueSendThread createSendThread(const SharedNodePointer& node);
virtual UniqueSendThread newSendThread(const SharedNodePointer& node);
//void replaceContentFromMessageData(QByteArray content);
int _argc;
const char** _argv;
char** _parsedArgV;

View file

@ -3234,6 +3234,13 @@ void DomainServer::maybeHandleReplacementEntityFile() {
} else {
qCDebug(domain_server) << "Replacing existing entity date with replacement file";
QFile replacementFile(replacementFilePath);
if (!replacementFile.remove()) {
// If we can't remove the replacement file, we are at risk of getting into a state where
// we continually replace the primary entity file with the replacement entity file.
qCWarning(domain_server)
<< "Unable to remove replacement file, bailing";
} else {
data.resetIdAndVersion();
auto gzippedData = data.toGzippedByteArray();
@ -3246,6 +3253,7 @@ void DomainServer::maybeHandleReplacementEntityFile() {
}
}
}
}
void DomainServer::handleOctreeFileReplacement(QByteArray octreeFile) {
// enumerate the nodes and find any octree type servers with active sockets

View file

@ -93,12 +93,7 @@ bool OctreeUtils::readOctreeFile(QString path, QJsonDocument* doc) {
QByteArray data = file.readAll();
QByteArray jsonData;
if (path.endsWith(".json.gz")) {
if (!gunzip(data, jsonData)) {
qCritical() << "json File not in gzip format: " << path;
return false;
}
} else {
jsonData = data;
}
@ -173,4 +168,5 @@ QByteArray OctreeUtils::RawOctreeData::toGzippedByteArray() {
void OctreeUtils::RawOctreeData::resetIdAndVersion() {
id = QUuid::createUuid();
version = OctreeUtils::INITIAL_VERSION;
qDebug() << "Reset octree data to: " << id << version;
}