From 5f20e0b3d234a677f01d9d9c5905a854e60e1d79 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Tue, 10 Nov 2026 15:37:08 -0600 Subject: [PATCH] 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 --- dDatabase/ModelNormalizeMigration.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/dDatabase/ModelNormalizeMigration.cpp b/dDatabase/ModelNormalizeMigration.cpp index 100f2ef19..d1864d1f6 100644 --- a/dDatabase/ModelNormalizeMigration.cpp +++ b/dDatabase/ModelNormalizeMigration.cpp @@ -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(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(newLxfml.data()), newLxfml.size());