forge
Explore
Log in

Don't you dare go Hollow

iz-web: multi-file upload reports the first failure, not the last file's luck

Browse files at this commit

f5cf7c521d182b0e23372bf6161a6cef3d6bf67aAhmet Kaan GümüşParent: a27a81d
crates/iz-web/src/files.rsmodified+7 -2
@@ -402,12 +402,14 @@ async fn upload(
402 Ok(backend) => backend,402 Ok(backend) => backend,
403 Err(_) => return Ok(back_to(&task_id, Some(Refusal::Unavailable))),403 Err(_) => return Ok(back_to(&task_id, Some(Refusal::Unavailable))),
404 };404 };
405+ // Every file is attempted; the redirect answers the FIRST failure, not
406+ // the last file's luck — an early loss must never read as success.
405 let mut added: Result<(), Refusal> = Ok(());407 let mut added: Result<(), Refusal> = Ok(());
406 for (file_name, bytes) in files {408 for (file_name, bytes) in files {
407 let label = label_of(&file_name);409 let label = label_of(&file_name);
408 let mime_type = sniff(&bytes);410 let mime_type = sniff(&bytes);
409 411
410- added = match backend {412+ let this = match backend {
411 StorageBackend::Local => store413 StorageBackend::Local => store
412 .add_attachment(NewAttachment {414 .add_attachment(NewAttachment {
413 task_id: &task_id,415 task_id: &task_id,
@@ -436,7 +438,7 @@ async fn upload(
436 }438 }
437 };439 };
438 440
439- if added.is_ok() && comment_id.is_none() {441+ if this.is_ok() && comment_id.is_none() {
440 let _ = store442 let _ = store
441 .record_activity(443 .record_activity(
442 &task_id,444 &task_id,
@@ -448,6 +450,9 @@ async fn upload(
448 )450 )
449 .await;451 .await;
450 }452 }
453+ if added.is_ok() {
454+ added = this;
455+ }
451 }456 }
452 457
453 Ok(match added {458 Ok(match added {