fix: the Kanban writes each file in _tmp and moves it in whole, so the FlexiPRINT never sees a temporary file (order #30)
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 6m28s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m3s

Chrome writes a .crswap working copy beside the file it writes. In the
hot folder the FlexiPRINT took each one as it appeared, the write failed
and every 30 s try left another; when the rename failed, the copy fallback
created the final name empty first and never removed it (0 KB files in
Arte conferida and maquina5\C2, Marcus 2026-11-17).

- Every file is written in _tmp, at the root of the chosen folder, under
  its own name, then moved under its final name into its folder.
- An empty file, or one shorter than the download's length, is deleted
  and reported in red (so in Sentry); the pass goes on and the next one
  tries it again.
- In the hot folders and Recibos a failed move is tried again; nothing
  is ever copied there. Elsewhere the copy stays, removes the final file
  if it fails, and reports to Sentry that it was used.
- Each page load clears the old .baixando and .crswap leftovers from the
  flow's folders; each pass clears tries over an hour old from _tmp.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-17 09:38:47 -03:00
parent bd25cb9c1c
commit b6837023bf
2 changed files with 90 additions and 28 deletions

View File

@@ -300,7 +300,9 @@ try{
// Other orders the earlier suites left in the queue may still be coming
// down: only once the round ends must no half-written file be left.
await waitFor(()=>kanban.eval('!FOLDER.busy'),'folder round finished',60000);
assert.equal((await savedFiles('2. Arte conferida')).some(n=>n.endsWith('.baixando')),false);
assert.equal((await savedFiles('2. Arte conferida')).some(n=>/\.(baixando|crswap)$/.test(n)),false);
// Written in the work folder and moved in whole: nothing stays there (order #30).
assert.deepEqual(await savedFiles('_tmp'),[]);
assert.equal((await savedFiles('1. Arte recebida')).some(n=>n.startsWith(prefix)),false);
// A file whose order was deleted leaves the folder.
await kanban.eval(`(async()=>{const dir=await window.picked.getDirectoryHandle('2. Arte conferida',{create:true});