fix: 96 DPI is accepted as the Site shows it; big carts upload 4 at a time (Sentry 12/11)
The server compared the raw lowest resolution (95,6) with 96 but printed it rounded, refusing '96 DPI abaixo do mínimo de 96'; it now decides on the same rounded value the Site shows. A big cart started every upload at once and hit the limit of 10 pending uploads (429): the limit is 30, that refusal carries Retry-After so the Site retries by itself, and the Site runs at most 4 uploads at a time. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
/* Shared direct multipart transport for customer originals/corrections and operator finals. */
|
||||
window.dtfUpload = async (file, {api, prefix='/uploads', startPath=prefix, progress=()=>{}, onBytes=()=>{}, scope='guest', resume=true, signal=null}) => {
|
||||
// A big cart would otherwise open dozens of server reservations at once and
|
||||
// meet the pending-upload cap. Four at a time, the rest queued here.
|
||||
const DTF_UPLOAD_SLOTS=4;
|
||||
let uploadSlotsUsed=0;
|
||||
const uploadSlotsWaiting=[];
|
||||
function uploadSlot(){
|
||||
if(uploadSlotsUsed<DTF_UPLOAD_SLOTS){uploadSlotsUsed++;return Promise.resolve();}
|
||||
return new Promise(resolve=>uploadSlotsWaiting.push(resolve));
|
||||
}
|
||||
function releaseUploadSlot(){
|
||||
const next=uploadSlotsWaiting.shift();
|
||||
if(next)next();else uploadSlotsUsed--;
|
||||
}
|
||||
async function sendUpload(file, {api, prefix='/uploads', startPath=prefix, progress=()=>{}, onBytes=()=>{}, scope='guest', resume=true, signal=null}) {
|
||||
const cancelled=()=>new DOMException('Envio cancelado.','AbortError');
|
||||
const samples=new Blob([file.slice(0,65536),file.slice(Math.max(0,file.size-65536))]);
|
||||
const hash=Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',await samples.arrayBuffer())),b=>b.toString(16).padStart(2,'0')).join('');
|
||||
@@ -76,4 +89,10 @@ window.dtfUpload = async (file, {api, prefix='/uploads', startPath=prefix, progr
|
||||
}
|
||||
await api(prefix+'/'+id+'/complete',{});
|
||||
return waitForScan();
|
||||
}
|
||||
window.dtfUpload = async (file, options) => {
|
||||
if(options?.signal?.aborted)throw new DOMException('Envio cancelado.','AbortError');
|
||||
await uploadSlot();
|
||||
try{return await sendUpload(file, options);}
|
||||
finally{releaseUploadSlot();}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user