mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +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);
|
||||
virtual UniqueSendThread newSendThread(const SharedNodePointer& node);
|
||||
|
||||
//void replaceContentFromMessageData(QByteArray content);
|
||||
|
||||
int _argc;
|
||||
const char** _argv;
|
||||
char** _parsedArgV;
|
||||
|
|
|
@ -3234,15 +3234,23 @@ void DomainServer::maybeHandleReplacementEntityFile() {
|
|||
} else {
|
||||
qCDebug(domain_server) << "Replacing existing entity date with replacement file";
|
||||
|
||||
data.resetIdAndVersion();
|
||||
auto gzippedData = data.toGzippedByteArray();
|
||||
|
||||
QFile currentFile(getEntitiesFilePath());
|
||||
if (!currentFile.open(QIODevice::WriteOnly)) {
|
||||
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)
|
||||
<< "Failed to update entities data file with replacement file, unable to open entities file for writing";
|
||||
<< "Unable to remove replacement file, bailing";
|
||||
} 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 jsonData;
|
||||
|
||||
if (path.endsWith(".json.gz")) {
|
||||
if (!gunzip(data, jsonData)) {
|
||||
qCritical() << "json File not in gzip format: " << path;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!gunzip(data, jsonData)) {
|
||||
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;
|
||||
}
|
Loading…
Reference in a new issue