feat: printing files go into each machine's hot folder, part by part (item 10)
All checks were successful
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m13s
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 3m56s

Pulled to Imprimindo, an order's files go as a copy into
3. Imprimindo/<máquina>/<C1|C2|C3>/, the class of each item (chosen in the
Kanban, or measured by the Site), where FlexiPRINT takes them (Dropstar's
third round, item 10). A film in parts goes to the same machine, in order,
never more than two parts in its folder: the next is written when Flexi
takes one. The card says "Parte 3/7 imprimindo · 4/7 ripando".

The server decides what each folder gets (app/hotfolder.py,
dtf_local.hot_parts) and the Kanban's computers write it: each part is
claimed by one computer, so Flexi never gets it twice; a claim that did not
finish goes back to the queue; a part gone from its folder was taken and is
never written again; a card that leaves Imprimindo or is cancelled has what
Flexi did not take deleted. A part without a class waits for one, and the
class may still change in Imprimindo until its file is written.

The folder sync also follows files one by one, so the parts of a film over
15 m are no longer taken for replaced copies of each other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-03 17:05:08 -03:00
parent 353935bed3
commit e3a5ad6fa0
6 changed files with 289 additions and 10 deletions

View File

@@ -212,6 +212,23 @@ CREATE TABLE IF NOT EXISTS dtf_local.print_parts (
FOREIGN KEY(order_id,item_index) REFERENCES dtf_local.print_files(order_id,item_index) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS print_parts_upload ON dtf_local.print_parts(upload_id);
-- What each machine's hot folder gets (item 10, app/hotfolder.py): one row per
-- file or part, per entry into Imprimindo (round), written by one computer.
CREATE TABLE IF NOT EXISTS dtf_local.hot_parts (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
order_id uuid NOT NULL REFERENCES dtf_local.orders(id) ON DELETE CASCADE,
round integer NOT NULL, seq integer NOT NULL, item_index integer NOT NULL,
upload_id uuid NOT NULL REFERENCES dtf_local.uploads(id) ON DELETE CASCADE,
name text NOT NULL, folder text,
state text NOT NULL DEFAULT 'queued'
CHECK(state IN ('queued','claimed','written','consumed','withdraw','gone')),
claimed_at timestamptz, claimed_by text, written_at timestamptz, done_at timestamptz,
created_at timestamptz NOT NULL DEFAULT now(),
UNIQUE(order_id, round, seq)
);
CREATE INDEX IF NOT EXISTS hot_parts_open ON dtf_local.hot_parts(order_id)
WHERE state IN ('queued','claimed','written','withdraw');
INSERT INTO dtf_local.print_parts(order_id,item_index,part,upload_id)
SELECT order_id,item_index,1,upload_id FROM dtf_local.print_files WHERE upload_id IS NOT NULL
ON CONFLICT DO NOTHING;