diff --git a/tests/upload_retry_test.mjs b/tests/upload_retry_test.mjs index 8eecb44..5c00245 100644 --- a/tests/upload_retry_test.mjs +++ b/tests/upload_retry_test.mjs @@ -210,6 +210,22 @@ const run = async (completeSteps, {abortAfter} = {}) => { const waits = delays.filter(d => d === 1000 || d === 5000); assert.ok(waits.filter(d => d === 1000).length === 150 && waits.includes(5000)); } +// The antivirus not answering (a deploy restarting it) is scanned again by the +// worker a minute later: the page waits through it (Sentry DTF-WEB-2F). +{ + scanStates = Array(70).fill('error'); + const {result, error} = await run([{}]); + assert.equal(error, undefined); + assert.equal(result, 'u1'); + scanStates = []; +} +// A refused file stops at once, with the server's reason. +{ + scanStates = ['pending', 'rejected']; + const {error} = await run([{}]); + assert.match(error?.message || '', /bloqueado pela verificação/); + scanStates = []; +} // A scan the server never finishes ends with the message, after its 15 minutes. { scanStates = Array(5000).fill('pending'); diff --git a/web/upload.js b/web/upload.js index d34124a..dabfccb 100644 --- a/web/upload.js +++ b/web/upload.js @@ -81,7 +81,11 @@ async function sendUpload(file, {api, prefix='/uploads', startPath=prefix, progr if(signal?.aborted)throw cancelled(); const checked=await api(prefix+'/'+id); if(checked.scan_state==='clean')return id; - if(['rejected','error'].includes(checked.scan_state))throw new Error(checked.scan_reason||'Arquivo bloqueado pela verificação de segurança.'); + if(checked.scan_state==='rejected')throw new Error(checked.scan_reason||'Arquivo bloqueado pela verificação de segurança.'); + // "error" is the antivirus not answering (restarting with a deploy): + // the worker scans the file again a minute later (app/scanning.py), so + // the page keeps waiting instead of showing the scanner's English + // reason (Sentry DTF-WEB-2F). progress('Verificando segurança de '+file.name+'…'); const pause=waited<150000?1000:5000; await new Promise(resolve=>setTimeout(resolve,pause));