mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-26 08:16:15 +02:00
Update entities recover backup to reset id and version
This commit is contained in:
parent
1aba89b908
commit
4b2e907ada
1 changed files with 19 additions and 8 deletions
|
@ -77,6 +77,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <quazip5/quazipfile.h>
|
#include <quazip5/quazipfile.h>
|
||||||
|
#include <OctreeUtils.h>
|
||||||
|
|
||||||
class EntitiesBackupHandler {
|
class EntitiesBackupHandler {
|
||||||
public:
|
public:
|
||||||
EntitiesBackupHandler(QString entitiesFilePath, QString entitiesReplacementFilePath) :
|
EntitiesBackupHandler(QString entitiesFilePath, QString entitiesReplacementFilePath) :
|
||||||
|
@ -111,18 +113,27 @@ public:
|
||||||
qCritical() << "Failed to open models.json.gz in backup";
|
qCritical() << "Failed to open models.json.gz in backup";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto data = zipFile.readAll();
|
auto rawData = zipFile.readAll();
|
||||||
|
|
||||||
|
zipFile.close();
|
||||||
|
|
||||||
|
OctreeUtils::RawOctreeData data;
|
||||||
|
if (!OctreeUtils::readOctreeDataInfoFromData(rawData, &data)) {
|
||||||
|
qCritical() << "Unable to parse octree data during backup recovery";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.resetIdAndVersion();
|
||||||
|
|
||||||
|
if (zipFile.getZipError() != UNZ_OK) {
|
||||||
|
qCritical() << "Failed to unzip models.json.gz: " << zipFile.getZipError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QFile entitiesFile { _entitiesReplacementFilePath };
|
QFile entitiesFile { _entitiesReplacementFilePath };
|
||||||
|
|
||||||
if (entitiesFile.open(QIODevice::WriteOnly)) {
|
if (entitiesFile.open(QIODevice::WriteOnly)) {
|
||||||
entitiesFile.write(data);
|
entitiesFile.write(data.toGzippedByteArray());
|
||||||
}
|
|
||||||
|
|
||||||
zipFile.close();
|
|
||||||
|
|
||||||
if (zipFile.getZipError() != UNZ_OK) {
|
|
||||||
qCritical() << "Failed to zip models.json.gz: " << zipFile.getZipError();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue