Refuse a truncated project, and drive the whole path from the probe

`upload_project_file` already existed - as a `GenericPrinter` trait method,
which is why a grep for `pub async fn` missed it and this commit nearly
reimplemented it. It logged `written` and `byte_count` next to each other and
never compared them, so a short write was something you could only notice by
reading the logs afterwards, and the next line printed the truncated file
anyway. A `.3mf` is a zip: cut the end off and the central directory goes with
it, so the printer gets an archive it cannot open. That is also the failure a
slow transfer invites, and this transfer is slow - 4.96 MB took 31.3s, so a
62 MB project is minutes of exposure.

`print-project <local> [name]` runs that method against a real printer, so
the harness tests the production entry point rather than the three pieces in
sequence. It deliberately takes no `--ams`: the whole point is that the
mapping comes out of the archive. Gated like `start`, on a terminal state and
`--yes-start-a-real-print`.

Confirmed end to end on the P1P (2026-10-15, with the owner's go-ahead), with
the same project the 2026-10-11 run used: the derivation read one PETG/GFG99/
`#2850E0` filament out of `Metadata/slice_info.config` and produced
`mapping=[3]`, padded to five trays; 297,227 bytes went up with an exact byte
count; `IDLE -> PREPARE -> RUNNING`. The AMS on that machine has slot 2 in
black and slot 3 in blue, same product and same `tray_info_idx`, so picking
slot 3 is the colour tie-break doing real work rather than a one-candidate
match.
This commit is contained in:
2026-10-15 22:32:31 +00:00
parent 7d4cf41999
commit df6dfca3ca
2 changed files with 70 additions and 0 deletions
+16
View File
@@ -1348,6 +1348,22 @@ impl GenericPrinter for BambuPrinter {
"uploaded a project file to the SD card root"
);
// These two were logged next to each other and never compared, which
// made a short write something you could only notice by reading the
// logs afterwards - and the next line would have printed the
// truncated file anyway. A `.3mf` is a zip: cut the end off and the
// central directory goes with it, so the printer gets an archive it
// cannot open rather than a partial model. It is also the failure a
// slow transfer invites, and this one is slow: 4.96 MB took 31.3s on
// a P1P (2026-10-15), so a 62 MB project is minutes of exposure.
if written != byte_count as u64 {
return Err(PrinterError(format!(
"{}: uploaded {written} bytes of {byte_count} - refusing to print a \
truncated project",
self.base.name
)));
}
self.start_uploaded_file(&file_name, &filament).await
}