iz-web: multi-file upload reports the first failure, not the last file's luck
Browse files at this commitf5cf7c521d182b0e23372bf6161a6cef3d6bf67aParent: a27a81d1 changed file +7 -2
crates/iz-web/src/files.rsmodified+7 -2
| @@ -402,12 +402,14 @@ async fn upload( | ||
| 402 | 402 | Ok(backend) => backend, |
| 403 | 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 | 407 | let mut added: Result<(), Refusal> = Ok(()); |
| 406 | 408 | for (file_name, bytes) in files { |
| 407 | 409 | let label = label_of(&file_name); |
| 408 | 410 | let mime_type = sniff(&bytes); |
| 409 | 411 | |
| 410 | - added = match backend { | |
| 412 | + let this = match backend { | |
| 411 | 413 | StorageBackend::Local => store |
| 412 | 414 | .add_attachment(NewAttachment { |
| 413 | 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 | 442 | let _ = store |
| 441 | 443 | .record_activity( |
| 442 | 444 | &task_id, |
| @@ -448,6 +450,9 @@ async fn upload( | ||
| 448 | 450 | ) |
| 449 | 451 | .await; |
| 450 | 452 | } |
| 453 | + if added.is_ok() { | |
| 454 | + added = this; | |
| 455 | + } | |
| 451 | 456 | } |
| 452 | 457 | |
| 453 | 458 | Ok(match added { |