mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 06:19:02 +02:00
Fix replacement octree data not working
This commit is contained in:
parent
2a667fcd60
commit
0bbbff95cd
3 changed files with 17 additions and 15 deletions
|
@ -176,8 +176,6 @@ protected:
|
||||||
UniqueSendThread createSendThread(const SharedNodePointer& node);
|
UniqueSendThread createSendThread(const SharedNodePointer& node);
|
||||||
virtual UniqueSendThread newSendThread(const SharedNodePointer& node);
|
virtual UniqueSendThread newSendThread(const SharedNodePointer& node);
|
||||||
|
|
||||||
//void replaceContentFromMessageData(QByteArray content);
|
|
||||||
|
|
||||||
int _argc;
|
int _argc;
|
||||||
const char** _argv;
|
const char** _argv;
|
||||||
char** _parsedArgV;
|
char** _parsedArgV;
|
||||||
|
|
|
@ -3234,15 +3234,23 @@ void DomainServer::maybeHandleReplacementEntityFile() {
|
||||||
} else {
|
} else {
|
||||||
qCDebug(domain_server) << "Replacing existing entity date with replacement file";
|
qCDebug(domain_server) << "Replacing existing entity date with replacement file";
|
||||||
|
|
||||||
data.resetIdAndVersion();
|
QFile replacementFile(replacementFilePath);
|
||||||
auto gzippedData = data.toGzippedByteArray();
|
if (!replacementFile.remove()) {
|
||||||
|
// If we can't remove the replacement file, we are at risk of getting into a state where
|
||||||
QFile currentFile(getEntitiesFilePath());
|
// we continually replace the primary entity file with the replacement entity file.
|
||||||
if (!currentFile.open(QIODevice::WriteOnly)) {
|
|
||||||
qCWarning(domain_server)
|
qCWarning(domain_server)
|
||||||
<< "Failed to update entities data file with replacement file, unable to open entities file for writing";
|
<< "Unable to remove replacement file, bailing";
|
||||||
} else {
|
} else {
|
||||||
currentFile.write(gzippedData);
|
data.resetIdAndVersion();
|
||||||
|
auto gzippedData = data.toGzippedByteArray();
|
||||||
|
|
||||||
|
QFile currentFile(getEntitiesFilePath());
|
||||||
|
if (!currentFile.open(QIODevice::WriteOnly)) {
|
||||||
|
qCWarning(domain_server)
|
||||||
|
<< "Failed to update entities data file with replacement file, unable to open entities file for writing";
|
||||||
|
} else {
|
||||||
|
currentFile.write(gzippedData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,12 +93,7 @@ bool OctreeUtils::readOctreeFile(QString path, QJsonDocument* doc) {
|
||||||
QByteArray data = file.readAll();
|
QByteArray data = file.readAll();
|
||||||
QByteArray jsonData;
|
QByteArray jsonData;
|
||||||
|
|
||||||
if (path.endsWith(".json.gz")) {
|
if (!gunzip(data, jsonData)) {
|
||||||
if (!gunzip(data, jsonData)) {
|
|
||||||
qCritical() << "json File not in gzip format: " << path;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
jsonData = data;
|
jsonData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,4 +168,5 @@ QByteArray OctreeUtils::RawOctreeData::toGzippedByteArray() {
|
||||||
void OctreeUtils::RawOctreeData::resetIdAndVersion() {
|
void OctreeUtils::RawOctreeData::resetIdAndVersion() {
|
||||||
id = QUuid::createUuid();
|
id = QUuid::createUuid();
|
||||||
version = OctreeUtils::INITIAL_VERSION;
|
version = OctreeUtils::INITIAL_VERSION;
|
||||||
|
qDebug() << "Reset octree data to: " << id << version;
|
||||||
}
|
}
|
Loading…
Reference in a new issue