ProductAndPriceCommands reads the reopened cache's own product handle; ship_cc.read treats a zero-byte file as holding no records

The test asked a second cache for the handle of an object loaded by the first (identity lookup, no handle); it now asks the reopened cache for its product. cultcache-py raises an Unpack error on a zero-byte file, so ship_cc.read names the empty file through its own shape refusal. Both commits build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-12 04:38:53 +02:00
commit a486a7cae2
2 changed files with 3 additions and 2 deletions

View file

@ -236,7 +236,7 @@ public sealed class ShipProductTests : IDisposable
var (hull, _, products) = ShipAuthoringStore.Load(path);
var product = Assert.Single(products);
using (var reopened = ShipAuthoringStore.Open(path))
Assert.Equal(ShipModCatalog.ProductKey("mod.skiff", _acme), reopened.TryGetHandle(product).Value.Key);
Assert.Equal(ShipModCatalog.ProductKey("mod.skiff", _acme), reopened.TryGetHandle(Assert.Single(reopened.GetAll<FactionProductData>())).Value.Key);
Assert.Equal(_acme, product.Manufacturer.Key);
Assert.Equal(ShipModCatalog.HullKey("mod.skiff"), product.Design.Key);
Assert.Equal(hull.Roles.Select(role => role.Name), product.Roles.Select(role => role.Role));

View file

@ -88,7 +88,8 @@ class ShipFile(NamedTuple):
def read(path: str, cultlib_packages: str) -> ShipFile:
cultcache, msgpack = _libraries(cultlib_packages)
store = cultcache.SingleFileMessagePackBackingStore(path)
envelopes = store.pull_all()
# cultcache-py raises an Unpack error on a zero-byte file; an empty file holds no records, so the shape refusal below names it.
envelopes = [] if Path(path).is_file() and Path(path).stat().st_size == 0 else store.pull_all()
ships = [envelope for envelope in envelopes if envelope.type == SCHEMA]
hulls = [envelope for envelope in envelopes if envelope.type == HULL_SCHEMA]
# Before S1 the hull lived inside the ship record. Saving such a file would preserve the stale hull under a ship that