'+(e.fase==='verificando' ? 'Verificando a segurança de '+nome+'…'
: 'Enviando '+nome+' · '+pct+'% · '+fmt(e.enviado)+' de '+fmt(f.size))+''+
@@ -148,14 +149,25 @@ function pintaEnvios(){
}).join('');
}
addEventListener('dtf-envio',agendaEnvios);
+// A failed upload goes again; one the phone can no longer read (Android,
+// DTF-WEB-2A) would fail the same way, so its file leaves the list and the
+// picker opens for the customer to choose it again.
+function refazEnvio(x, lista){
+ if(!x) return;
+ if(!dtfEnvio.estado(x.f)?.escolher){ dtfEnvio.deNovo(x.f); return; }
+ const i=lista.indexOf(x);
+ if(i>=0){ lista.splice(i,1); lista===folhas?pintaFolha():pintaArtes(); }
+ $('inp').click();
+}
$('envios').addEventListener('click',e=>{
const b=e.target.closest('[data-envio]'); if(!b || !MODOS[modo]) return;
- const x=(ehFolha()?folhas:artes)[+b.dataset.envio]; if(x) dtfEnvio.deNovo(x.f);
+ const lista=ehFolha()?folhas:artes;
+ refazEnvio(lista[+b.dataset.envio], lista);
});
$('lista').addEventListener('click',e=>{
const b=e.target.closest('[data-envio-card]'); if(!b || !window.dtfEnvio) return;
- const x=(b.dataset.envioCard==='folha'?folhas:artes)[+b.dataset.envioIndex];
- if(x) dtfEnvio.deNovo(x.f);
+ const lista=b.dataset.envioCard==='folha'?folhas:artes;
+ refazEnvio(lista[+b.dataset.envioIndex], lista);
});
// A sheet with residue gets its preview circled where the dots are.
async function marcaResiduos(x){
diff --git a/web/upload.js b/web/upload.js
index f294121..81d19be 100644
--- a/web/upload.js
+++ b/web/upload.js
@@ -15,7 +15,19 @@ function releaseUploadSlot(){
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('');
+ // A phone can lose the right to read a file it picked (Android: a file from
+ // Drive or Photos, after switching apps). The browser's message is English
+ // and a retry reads the same dead reference: picking the file again is the
+ // way out (Sentry DTF-WEB-2A).
+ let sampled;
+ try{ sampled=await samples.arrayBuffer(); }
+ catch(error){
+ if(error?.name!=='NotReadableError' && error?.name!=='NotFoundError') throw error;
+ const unreadable=new Error('não conseguimos ler este arquivo no aparelho. Escolha o arquivo de novo');
+ unreadable.unreadable=true;
+ throw unreadable;
+ }
+ const hash=Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',sampled)),b=>b.toString(16).padStart(2,'0')).join('');
const key='dtf-upload:'+JSON.stringify([scope,file.name,file.size,file.lastModified,hash]);
// A busy server asks for a wait: retry this file alone, quietly, before the
// customer sees the failure (Marcus, 2026-11-11). Only a 429 that carries