fix: the model migrations leave a model they can not read as it is

When the data of a model could not be inflated, the two later position
migrations went on with an empty model and wrote the result back. All
three now log the model and leave its row alone. The first migration's
log line also gets the model ID it formats.

The client's own sd0 reader has no limit on the chunks or on the
inflated size, so the limits of the reader here stay well above any
model: a chunk inflates to at most 256 KiB, and 64 MiB is 256 full
chunks.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 15:37:08 -06:00
parent b3f5cd74df
commit 5f20e0b3d2

View File

@@ -14,9 +14,14 @@ void ModelNormalizeMigration::Run() {
Sd0 sd0(lxfmlData);
const auto asStr = sd0.GetAsStringUncompressed();
if (asStr.empty()) {
// Nothing to work from, so the model stays as it is stored
LOG("Could not read the data of model %llu, leaving it as it is.", modelID);
continue;
}
const auto [newLxfml, newCenter] = Lxfml::NormalizePositionOnlyFirstPart(asStr);
if (newCenter == NiPoint3Constant::ZERO) {
LOG("Failed to update model %llu due to failure reading xml.");
LOG("Failed to update model %llu due to failure reading xml.", modelID);
continue;
}
@@ -39,6 +44,11 @@ void ModelNormalizeMigration::RunAfterFirstPart() {
Sd0 sd0(lxfmlData);
const auto asStr = sd0.GetAsStringUncompressed();
if (asStr.empty()) {
// Nothing to work from, so the model stays as it is stored
LOG("Could not read the data of model %llu, leaving it as it is.", modelID);
continue;
}
const auto [newLxfml, newCenter] = Lxfml::NormalizePositionAfterFirstPart(asStr, model->position);
sd0.FromData(reinterpret_cast<const uint8_t*>(newLxfml.data()), newLxfml.size());
@@ -59,6 +69,11 @@ void ModelNormalizeMigration::RunBrickBuildGrid() {
Sd0 sd0(lxfmlData);
const auto asStr = sd0.GetAsStringUncompressed();
if (asStr.empty()) {
// Nothing to work from, so the model stays as it is stored
LOG("Could not read the data of model %llu, leaving it as it is.", modelID);
continue;
}
const auto [newLxfml, newCenter] = Lxfml::NormalizePosition(asStr, model->position);
sd0.FromData(reinterpret_cast<const uint8_t*>(newLxfml.data()), newLxfml.size());