mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-26 13:57:42 -05:00
feat(server): take nest record counts, material and thickness from the archive
The server stored whatever plate count, part count, material and thickness the client claimed, so a record could disagree with its own archive, and a bulk importer had to read each written .nest back in full just to describe it (about a quarter of the PEP archive import's time). Uploads (POST and PUT /file) now read only the archive's nest.json - never programs or geometry, and without referencing OpenNest.IO - and overwrite those fields, following NestReader's fallbacks for thickness, material, parts with a missing drawing and the trailing new-plate slot. A file without a readable nest.json is 400 and stores nothing, so the server can guarantee the record describes the bytes; nest.json decompression stops at 64 MB. A metadata-only PUT keeps the stored counts because the archive is unchanged; material and thickness stay editable there, since the desktop applies the record's values on open. Server tests that uploaded placeholder bytes now upload small deterministic archives, and the container smoke's near-limit probe is a padded real archive. New tests pin the server's values to a full NestReader read of the same archive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0eb6d5886a
commit
64e24fc6c8
12 files changed
+446
-73
No files matched your search
@@ -203,7 +203,12 @@ static async Task<(NestRecord? Record, byte[]? File, IResult? Error)> ReadMultip
|
||||
using var stream = filePart.OpenReadStream();
|
||||
using var buffer = new MemoryStream((int)filePart.Length);
|
||||
await stream.CopyToAsync(buffer);
|
||||
return (record, buffer.ToArray(), null);
|
||||
var file = buffer.ToArray();
|
||||
|
||||
// Counts, material and thickness come from the archive itself, not the client's claim.
|
||||
if (NestArchive.Apply(record, file) is { } archiveError)
|
||||
return (null, null, Results.BadRequest(archiveError));
|
||||
return (record, file, null);
|
||||
}
|
||||
|
||||
// Entry-point type for in-memory integration tests (WebApplicationFactory<Program>).
|
||||
|
||||
Reference in new issue
Block a user