From 2ff11688bc71970fe57a575609cf7092b38dff03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Fri, 27 Nov 2026 16:25:20 -0300 Subject: [PATCH] fix: the folders change only the files of orders the server answered for MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Kanban asks the server about at most 1000 orders a pass; an order left out had no state in the answer and was taken for deleted, so its files left the folders although it was still in Correção or Revisão. Orders still in the flow are asked first, then those in Finalizado, and a file whose order was not asked this pass stays as it is. Co-Authored-By: Claude Opus 5.5 --- web/kanban.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/web/kanban.js b/web/kanban.js index 66a22d5..95a4824 100644 --- a/web/kanban.js +++ b/web/kanban.js @@ -626,7 +626,14 @@ async function syncFolder(force=false){ FOLDER.busy=true; try{ if(stages)await makeStageFolders(); - const held=stages?[...new Set([...FOLDER.saved.values()].filter(r=>!r.review).map(r=>r.order).filter(Boolean))].slice(-1000):[]; + // The server answers for up to 1000 orders a pass: the ones still in the + // flow first, then those in Finalizado. A file whose order was not asked + // this time stays as it is; only an order the server says is gone, + // cancelled or moved changes its files. + const records=[...FOLDER.saved.values()].filter(r=>!r.review&&r.order); + const held=stages?[...new Set([...records.filter(r=>r.folder!==STAGE_FOLDERS.fin),...records.filter(r=>r.folder===STAGE_FOLDERS.fin)] + .map(r=>r.order))].slice(0,1000):[]; + const asked=new Set(held); const {files,states,receipts=[],reviews=[]}=await api('/queue/folder',{early:stages,held,since:stages?FOLDER.since||await folderSince():null}); // By file: an item longer than a part (10 m) is several parts (item 13), each its own file. const wanted=new Map(files.map(f=>[f.upload_id,f])); @@ -642,7 +649,7 @@ async function syncFolder(force=false){ ...(folder===STAGE_FOLDERS.fin?{at:file.at||Date.now()}:{})}); FOLDER.last=new Date();await keepSaved();}; if(stages)for(const [uid,rec] of [...FOLDER.saved])await step(rec.name,async()=>{ - if(!rec.order||!rec.folder)return; + if(!rec.order||!rec.folder||!asked.has(rec.order))return; const state=states[rec.order], target=STAGE_FOLDERS[state]; const now=wanted.get(uid); const replaced=(state==='rec'||state==='tra')&&(!now||now.order!==rec.order);