큰 작업 승인과 안전한 확대 재시도를 화면에 연결한다
- 작성자
- 호시노 히나타
- 작성 시각
- 커밋
822ad1e4c859c100197f1fa501095bb6d0ab8a9c- 부모
- 6565a4b
변경된 파일 13개
+1,121-15| @@ -97,3 +97,23 @@ python3 tests/ci/run_rust.py local | ||
| 97 | 97 | |
| 98 | 98 | |
| 99 | 99 | TAR.BZ2와 TAR.XZ의 자동 해제 폴더 이름은 미리보기에 표시되지 않는다. tests/rust-app-ui/presentation.rs의 이름 시험과 tests/rust-app-real-worker/compressed_tar_flows.rs의 실제 작업자 시험에서 복합 확장자 제거와 해제 결과를 확인한다. |
| 100 | 추가: | |
| 101 | 추가: ## 큰 작업의 승인과 재시도 | |
| 102 | 추가: | |
| 103 | 추가: - resource-approval: 목록에서 큰 작업임을 확인한 뒤 처리 전 승인을 묻는 화면 | |
| 104 | 추가: - resource-ratio: 압축률 경고와 미확인 예상값을 표시하는 화면 | |
| 105 | 추가: - resource-retry: 출력 없이 한도에 걸린 뒤 "한도를 늘려 다시 시도"를 고르는 화면 | |
| 106 | 추가: - resource-partial: 일부 파일을 저장한 뒤 한도에 걸려 저장 위치를 안내하는 화면 | |
| 107 | 추가: | |
| 108 | 추가: 일반 작업은 16 GiB와 10,000개 한도를 유지하며 압축률을 감시합니다. | |
| 109 | 추가: 목록이나 선택한 일반 파일의 크기로 한도 초과를 알면 처리 전에 작업자가 확대 승인을 묻습니다. | |
| 110 | 추가: 미리 알 수 없는 폴더 내부와 압축파일은 기본 한도로 시작합니다. | |
| 111 | 추가: 출력이 없고 임시 파일 정리와 작업자 종료가 확인된 한도 오류에서만 확대 재시도를 제공합니다. | |
| 112 | 추가: 확대 재시도를 선택해도 작업자의 승인 질문에서 "이 작업 허용"을 눌러야 진행합니다. | |
| 113 | 추가: 이미 저장되거나 일부 남은 파일, 저장 상태나 정리가 불확실한 작업은 확대 재시도를 제공하지 않습니다. | |
| 114 | 추가: | |
| 115 | 추가: 승인은 해당 작업과 질문 범위에만 적용합니다. 예상값, 실제값과 저장 볼륨의 여유 공간은 구분하며 | |
| 116 | 추가: 확인하지 못한 값은 "미확인"으로 표시합니다. 여유 공간은 예약이나 모든 볼륨의 합계가 아닙니다. | |
| 117 | 추가: 승인 후에도 상한과 공간 검사를 유지합니다. 취소 버튼과 Escape는 승인 대기 중 작업을 취소합니다. | |
| 118 | 추가: Enter만으로 허용하지 않습니다. 기존 작업자로 자동 재시도하지 않습니다. | |
| 119 | 추가: 미리보기는 입력과 파일 쓰기를 막으며 실제 64 GiB 작업을 수행하지 않습니다. |
| @@ -228,6 +228,21 @@ fn event_to_ui( | ||
| 228 | 228 | wire::Message::Accepted { action, encryption } if expected == Some(action) => { |
| 229 | 229 | ui::Event::Accepted { encryption } |
| 230 | 230 | } |
| 231 | 추가: wire::Message::ResourceRequired { | |
| 232 | 추가: challenge_id, | |
| 233 | 추가: action, | |
| 234 | 추가: scope, | |
| 235 | 추가: usage, | |
| 236 | 추가: soft_limits, | |
| 237 | 추가: ceiling, | |
| 238 | 추가: } if expected == Some(action) => ui::Event::ResourceRequired(ui::ResourceChallenge { | |
| 239 | 추가: id: challenge_id, | |
| 240 | 추가: action, | |
| 241 | 추가: scope, | |
| 242 | 추가: usage, | |
| 243 | 추가: soft_limits, | |
| 244 | 추가: ceiling, | |
| 245 | 추가: }), | |
| 231 | 246 | wire::Message::Entry(entry) => ui::Event::Entry(ui::Entry { |
| 232 | 247 | id: entry.entry_id, |
| 233 | 248 | name: entry.name, |
| @@ -451,15 +466,38 @@ impl ui::Connection for ProcessConnection { | ||
| 451 | 466 | return Err("작업자 요청 채널이 닫혔거나 순서가 올바르지 않습니다".into()); |
| 452 | 467 | } |
| 453 | 468 | let is_cancel = matches!(request.command, ui::Command::Cancel); |
| 469 | 추가: let expanded = matches!(&request.command, ui::Command::StartExpanded(_)); | |
| 454 | 470 | let message = match request.command { |
| 455 | 삭제: ui::Command::Start(start) => { | |
| 471 | 추가: ui::Command::Start(start) | ui::Command::StartExpanded(start) => { | |
| 456 | 472 | let start = start_to_wire(start); |
| 457 | 473 | *self.expected.lock().map_err(|_| { |
| 458 | 474 | self.stop.store(true, Ordering::Release); |
| 459 | 475 | "작업자 요청 상태 오류" |
| 460 | 476 | })? = Some(start.action.kind()); |
| 461 | 삭제: wire::Message::Start(start) | |
| 477 | 추가: let ceiling = if expanded { | |
| 478 | 추가: wire::Limits { | |
| 479 | 추가: input: u64::MAX, | |
| 480 | 추가: output: 64 * 1024 * 1024 * 1024, | |
| 481 | 추가: entries: 200_000, | |
| 482 | 추가: } | |
| 483 | 추가: } else { | |
| 484 | 추가: wire::Limits::default() | |
| 485 | 추가: }; | |
| 486 | 추가: wire::Message::StartGuarded(wire::GuardedStart { | |
| 487 | 추가: start, | |
| 488 | 추가: ceiling, | |
| 489 | 추가: interactive: false, | |
| 490 | 추가: }) | |
| 462 | 491 | } |
| 492 | 추가: ui::Command::ResourceReply { | |
| 493 | 추가: challenge_id, | |
| 494 | 추가: scope, | |
| 495 | 추가: allow, | |
| 496 | 추가: } => wire::Message::ResourceReply { | |
| 497 | 추가: challenge_id, | |
| 498 | 추가: scope, | |
| 499 | 추가: allow, | |
| 500 | 추가: }, | |
| 463 | 501 | ui::Command::Cancel => wire::Message::Cancel, |
| 464 | 502 | ui::Command::Password { |
| 465 | 503 | challenge_id, |
| @@ -1012,6 +1012,7 @@ impl ArchiveApp { | ||
| 1012 | 1012 | if self.model.challenge.is_some() { |
| 1013 | 1013 | self.password_dialog(&ctx, new_challenge); |
| 1014 | 1014 | } |
| 1015 | 추가: self.resource_dialog(&ctx); | |
| 1015 | 1016 | self.close_dialog(&ctx); |
| 1016 | 1017 | self.picker_notice(&ctx); |
| 1017 | 1018 | if self.custom_frame { |
| @@ -1593,6 +1594,7 @@ impl ArchiveApp { | ||
| 1593 | 1594 | (self.create && !self.model.busy()) |
| 1594 | 1595 | || self.picker.is_some() |
| 1595 | 1596 | || self.model.challenge.is_some() |
| 1597 | 추가: || self.model.resource.is_some() | |
| 1596 | 1598 | || self.model.close != Close::Open |
| 1597 | 1599 | } |
| 1598 | 1600 | |
| @@ -1718,6 +1720,13 @@ impl ArchiveApp { | ||
| 1718 | 1720 | } |
| 1719 | 1721 | |
| 1720 | 1722 | fn progress(&mut self, ui: &mut egui::Ui) { |
| 1723 | 추가: if self.model.resource.is_some() { | |
| 1724 | 추가: ui.horizontal(|ui| { | |
| 1725 | 추가: ui.label("사용자 허용을 기다리고 있습니다"); | |
| 1726 | 추가: self.cancel_action(ui, false); | |
| 1727 | 추가: }); | |
| 1728 | 추가: return; | |
| 1729 | 추가: } | |
| 1721 | 1730 | let creating = matches!(self.last_request, Some(Start::CreateZip { .. })); |
| 1722 | 1731 | let cancelling = self.model.cancellation_requested() || self.model.cancel.is_some(); |
| 1723 | 1732 | let title = present::activity_text(&self.model, creating); |
| @@ -1824,6 +1833,7 @@ impl ArchiveApp { | ||
| 1824 | 1833 | }; |
| 1825 | 1834 | let mut choose = false; |
| 1826 | 1835 | let mut retry = false; |
| 1836 | 추가: let mut expand = false; | |
| 1827 | 1837 | let mut reopen = false; |
| 1828 | 1838 | let mut folder = false; |
| 1829 | 1839 | theme::panel(fill).show(ui, |ui| { |
| @@ -1893,6 +1903,22 @@ impl ArchiveApp { | ||
| 1893 | 1903 | "아무 파일도 풀지 않았습니다" |
| 1894 | 1904 | }); |
| 1895 | 1905 | } |
| 1906 | 추가: if t.as_ref().is_some_and(|t| { | |
| 1907 | 추가: t.error == Some(ErrorCode::Limit) | |
| 1908 | 추가: && (t.created_count > 0 | |
| 1909 | 추가: || t.retained_partial_count > 0 | |
| 1910 | 추가: || t.publication != Publication::None) | |
| 1911 | 추가: }) { | |
| 1912 | 추가: ui.label(format!( | |
| 1913 | 추가: "{}개 파일이 저장되었거나 일부 남아 있습니다. 저장 위치를 확인하세요.", | |
| 1914 | 추가: t.as_ref().unwrap().created_count | |
| 1915 | 추가: )); | |
| 1916 | 추가: theme::bounded_text( | |
| 1917 | 추가: ui, | |
| 1918 | 추가: &self.destination.display().to_string(), | |
| 1919 | 추가: ui.available_width(), | |
| 1920 | 추가: ); | |
| 1921 | 추가: } | |
| 1896 | 1922 | if self.details { |
| 1897 | 1923 | theme::panel(theme::STRIPE).show(ui, |ui| { |
| 1898 | 1924 | if durability_in_details { |
| @@ -1974,6 +2000,13 @@ impl ArchiveApp { | ||
| 1974 | 2000 | }, |
| 1975 | 2001 | true, |
| 1976 | 2002 | )) |
| 2003 | 추가: } else if self.model.can_retry_expanded() { | |
| 2004 | 추가: None | |
| 2005 | 추가: } else if t | |
| 2006 | 추가: .as_ref() | |
| 2007 | 추가: .is_some_and(|t| t.error == Some(ErrorCode::Limit)) | |
| 2008 | 추가: { | |
| 2009 | 추가: None | |
| 1977 | 2010 | } else if !cancelled && (!uncertain || listing) { |
| 1978 | 2011 | Some(("다시 시도", true)) |
| 1979 | 2012 | } else { |
| @@ -1997,6 +2030,11 @@ impl ArchiveApp { | ||
| 1997 | 2030 | } |
| 1998 | 2031 | } |
| 1999 | 2032 | }); |
| 2033 | 추가: if self.model.can_retry_expanded() { | |
| 2034 | 추가: ui.with_layout(Layout::right_to_left(Align::Center), |ui| { | |
| 2035 | 추가: expand = theme::action(ui, "한도를 늘려 다시 시도", true, true).clicked(); | |
| 2036 | 추가: }); | |
| 2037 | 추가: } | |
| 2000 | 2038 | }); |
| 2001 | 2039 | if choose { |
| 2002 | 2040 | self.open_picker(Purpose::Retry); |
| @@ -2004,6 +2042,27 @@ impl ArchiveApp { | ||
| 2004 | 2042 | if retry { |
| 2005 | 2043 | self.retry(); |
| 2006 | 2044 | } |
| 2045 | 추가: if expand { | |
| 2046 | 추가: let ready = if matches!(self.last_request, Some(Start::Extract { .. })) { | |
| 2047 | 추가: match present::prepare_destination(&self.destination, self.automatic_destination) { | |
| 2048 | 추가: Ok(created) => { | |
| 2049 | 추가: self.owned_destination = created.then(|| self.destination.clone()); | |
| 2050 | 추가: true | |
| 2051 | 추가: } | |
| 2052 | 추가: Err(_) => { | |
| 2053 | 추가: self.ui_error = Some(present::FOLDER_ERROR.into()); | |
| 2054 | 추가: false | |
| 2055 | 추가: } | |
| 2056 | 추가: } | |
| 2057 | 추가: } else { | |
| 2058 | 추가: true | |
| 2059 | 추가: }; | |
| 2060 | 추가: if ready && self.model.retry_expanded(self.factory.as_mut()) { | |
| 2061 | 추가: self.dismissed = false; | |
| 2062 | 추가: self.details = false; | |
| 2063 | 추가: self.ui_error = None; | |
| 2064 | 추가: } | |
| 2065 | 추가: } | |
| 2007 | 2066 | if reopen { |
| 2008 | 2067 | if let Some(path) = self.model.archive.clone() { |
| 2009 | 2068 | self.open_path(path); |
| @@ -2383,6 +2442,98 @@ impl ArchiveApp { | ||
| 2383 | 2442 | cancel |
| 2384 | 2443 | } |
| 2385 | 2444 | |
| 2445 | 추가: fn resource_dialog(&mut self, ctx: &egui::Context) { | |
| 2446 | 추가: let Some(question) = self.model.resource.clone() else { | |
| 2447 | 추가: return; | |
| 2448 | 추가: }; | |
| 2449 | 추가: let Some(job) = self.model.job_id() else { | |
| 2450 | 추가: return; | |
| 2451 | 추가: }; | |
| 2452 | 추가: let mut allow = false; | |
| 2453 | 추가: let mut cancel = false; | |
| 2454 | 추가: let modal = egui::Modal::new(egui::Id::unique(("archive-resource", job, question.id))) | |
| 2455 | 추가: .show(ctx, |ui| { | |
| 2456 | 추가: ui.set_width((ctx.content_rect().width() - 64.0).min(460.0)); | |
| 2457 | 추가: ui.heading(if question.scope.ratio { | |
| 2458 | 추가: "압축률이 매우 높습니다" | |
| 2459 | 추가: } else { | |
| 2460 | 추가: "큰 작업을 허용할까요?" | |
| 2461 | 추가: }); | |
| 2462 | 추가: ui.label(match question.action { | |
| 2463 | 추가: ActionKind::List => "압축파일 목록 열기", | |
| 2464 | 추가: ActionKind::Extract => "압축 해제", | |
| 2465 | 추가: ActionKind::CreateZip => "ZIP 만들기", | |
| 2466 | 추가: }); | |
| 2467 | 추가: if question.scope.ratio { | |
| 2468 | 추가: ui.label("작은 압축파일도 많은 저장 공간을 사용할 수 있습니다."); | |
| 2469 | 추가: } | |
| 2470 | 추가: if question.scope.output { | |
| 2471 | 추가: ui.label(format!( | |
| 2472 | 추가: "총량 한도: {}에서 {}로", | |
| 2473 | 추가: present::bytes_text(question.soft_limits.output), | |
| 2474 | 추가: present::bytes_text(question.ceiling.output) | |
| 2475 | 추가: )); | |
| 2476 | 추가: } | |
| 2477 | 추가: if question.scope.entries { | |
| 2478 | 추가: ui.label(format!( | |
| 2479 | 추가: "항목 한도: {}개에서 {}개로", | |
| 2480 | 추가: question.soft_limits.entries, question.ceiling.entries | |
| 2481 | 추가: )); | |
| 2482 | 추가: } | |
| 2483 | 추가: let mut u = question.usage; | |
| 2484 | 추가: let estimated = self.model.estimated_usage(); | |
| 2485 | 추가: u.estimated_bytes = u.estimated_bytes.or(estimated.estimated_bytes); | |
| 2486 | 추가: u.estimated_entries = u.estimated_entries.or(estimated.estimated_entries); | |
| 2487 | 추가: let bytes = |value: Option<u64>| { | |
| 2488 | 추가: value | |
| 2489 | 추가: .map(present::bytes_text) | |
| 2490 | 추가: .unwrap_or_else(|| "미확인".into()) | |
| 2491 | 추가: }; | |
| 2492 | 추가: let entries = |value: Option<u32>| { | |
| 2493 | 추가: value | |
| 2494 | 추가: .map(|n| format!("{n}개")) | |
| 2495 | 추가: .unwrap_or_else(|| "미확인".into()) | |
| 2496 | 추가: }; | |
| 2497 | 추가: ui.label(format!( | |
| 2498 | 추가: "예상 총량: {} / 실제 총량: {}", | |
| 2499 | 추가: bytes(u.estimated_bytes), | |
| 2500 | 추가: bytes(u.actual_bytes) | |
| 2501 | 추가: )); | |
| 2502 | 추가: ui.label(format!( | |
| 2503 | 추가: "예상 항목: {} / 실제 항목: {}", | |
| 2504 | 추가: entries(u.estimated_entries), | |
| 2505 | 추가: entries(u.actual_entries) | |
| 2506 | 추가: )); | |
| 2507 | 추가: if question.scope.ratio { | |
| 2508 | 추가: ui.label(format!( | |
| 2509 | 추가: "압축 크기: {} / 풀린 크기: {}", | |
| 2510 | 추가: bytes(u.compressed_bytes), | |
| 2511 | 추가: bytes(u.ratio_output_bytes) | |
| 2512 | 추가: )); | |
| 2513 | 추가: } | |
| 2514 | 추가: ui.label(format!( | |
| 2515 | 추가: "확인한 저장 볼륨의 여유 공간: {}", | |
| 2516 | 추가: bytes(u.available_bytes) | |
| 2517 | 추가: )); | |
| 2518 | 추가: ui.label(format!( | |
| 2519 | 추가: "이 작업의 상한: {} / {}개", | |
| 2520 | 추가: present::bytes_text(question.ceiling.output), | |
| 2521 | 추가: question.ceiling.entries | |
| 2522 | 추가: )); | |
| 2523 | 추가: ui.label("이 작업에만 적용합니다. 공간 부족이나 자원 상한에 도달하면 중단합니다."); | |
| 2524 | 추가: ui.horizontal(|ui| { | |
| 2525 | 추가: cancel = theme::action(ui, "취소", false, true).clicked(); | |
| 2526 | 추가: allow = theme::action(ui, "이 작업 허용", true, true).clicked(); | |
| 2527 | 추가: }); | |
| 2528 | 추가: }); | |
| 2529 | 추가: if cancel || modal.should_close() { | |
| 2530 | 추가: self.clear_password(); | |
| 2531 | 추가: self.model.cancel(); | |
| 2532 | 추가: } else if allow { | |
| 2533 | 추가: self.model.resource_reply(job, question.id, true); | |
| 2534 | 추가: } | |
| 2535 | 추가: } | |
| 2536 | 추가: | |
| 2386 | 2537 | fn password_dialog(&mut self, ctx: &egui::Context, new_challenge: bool) { |
| 2387 | 2538 | let (_, attempt, encrypt) = self.model.challenge.unwrap(); |
| 2388 | 2539 | let mut submit = false; |
| @@ -72,7 +72,16 @@ impl Drop for Secret { | ||
| 72 | 72 | } |
| 73 | 73 | pub enum Command { |
| 74 | 74 | Start(Start), |
| 75 | 삭제: Password { challenge_id: u64, secret: Secret }, | |
| 75 | 추가: StartExpanded(Start), | |
| 76 | 추가: ResourceReply { | |
| 77 | 추가: challenge_id: u64, | |
| 78 | 추가: scope: ResourceScope, | |
| 79 | 추가: allow: bool, | |
| 80 | 추가: }, | |
| 81 | 추가: Password { | |
| 82 | 추가: challenge_id: u64, | |
| 83 | 추가: secret: Secret, | |
| 84 | 추가: }, | |
| 76 | 85 | Cancel, |
| 77 | 86 | } |
| 78 | 87 | pub struct Request { |
| @@ -171,8 +180,20 @@ pub struct Terminal { | ||
| 171 | 180 | pub durability: Durability, |
| 172 | 181 | pub cleanup: Cleanup, |
| 173 | 182 | } |
| 183 | 추가: pub use worker_protocol::protocol::{ActionKind, Limits, ResourceScope, ResourceUsage}; | |
| 184 | 추가: #[derive(Clone, Debug)] | |
| 185 | 추가: pub struct ResourceChallenge { | |
| 186 | 추가: pub id: u64, | |
| 187 | 추가: pub action: ActionKind, | |
| 188 | 추가: pub scope: ResourceScope, | |
| 189 | 추가: pub usage: ResourceUsage, | |
| 190 | 추가: pub soft_limits: Limits, | |
| 191 | 추가: pub ceiling: Limits, | |
| 192 | 추가: } | |
| 193 | 추가: | |
| 174 | 194 | #[derive(Clone, Debug)] |
| 175 | 195 | pub enum Event { |
| 196 | 추가: ResourceRequired(ResourceChallenge), | |
| 176 | 197 | Accepted { |
| 177 | 198 | encryption: bool, |
| 178 | 199 | }, |
| @@ -247,6 +268,10 @@ struct Running { | ||
| 247 | 268 | stderr_eof: bool, |
| 248 | 269 | exit: Option<bool>, |
| 249 | 270 | cancel_sequence: Option<u64>, |
| 271 | 추가: expanded: bool, | |
| 272 | 추가: granted: ResourceScope, | |
| 273 | 추가: last_challenge: u64, | |
| 274 | 추가: estimated: ResourceUsage, | |
| 250 | 275 | } |
| 251 | 276 | #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] |
| 252 | 277 | pub enum Close { |
| @@ -267,6 +292,8 @@ pub struct Model { | ||
| 267 | 292 | pub selected: BTreeSet<u32>, |
| 268 | 293 | pub terminal: Option<Terminal>, |
| 269 | 294 | pub challenge: Option<(u64, u32, bool)>, |
| 295 | 추가: pub resource: Option<ResourceChallenge>, | |
| 296 | 추가: retry_start: Option<Start>, | |
| 270 | 297 | pub progress: Option<(Stage, u64, Option<u64>, u64)>, |
| 271 | 298 | pub outputs: Vec<(String, Disposition)>, |
| 272 | 299 | pub cancel: Option<CancelStatus>, |
| @@ -295,9 +322,121 @@ impl Model { | ||
| 295 | 322 | && self.close == Close::Open |
| 296 | 323 | } |
| 297 | 324 | pub fn begin(&mut self, start: Start, factory: &mut dyn Factory) -> bool { |
| 325 | 추가: let expanded = self.needs_expansion(&start); | |
| 326 | 추가: self.begin_with_limits(start, factory, expanded) | |
| 327 | 추가: } | |
| 328 | 추가: pub fn estimated_usage(&self) -> ResourceUsage { | |
| 329 | 추가: self.running | |
| 330 | 추가: .as_ref() | |
| 331 | 추가: .map(|run| run.estimated) | |
| 332 | 추가: .unwrap_or_default() | |
| 333 | 추가: } | |
| 334 | 추가: fn estimate(&self, start: &Start) -> ResourceUsage { | |
| 335 | 추가: let mut usage = ResourceUsage::default(); | |
| 336 | 추가: match start { | |
| 337 | 추가: Start::Extract { selection, .. } => { | |
| 338 | 추가: let selected_ids: BTreeSet<_> = match selection { | |
| 339 | 추가: Selection::All => BTreeSet::new(), | |
| 340 | 추가: Selection::EntryIds(ids) => ids.iter().copied().collect(), | |
| 341 | 추가: }; | |
| 342 | 추가: let directories: BTreeSet<_> = self | |
| 343 | 추가: .entries | |
| 344 | 추가: .iter() | |
| 345 | 추가: .filter(|e| selected_ids.contains(&e.id) && e.kind == Kind::Directory) | |
| 346 | 추가: .map(|e| e.name.trim_end_matches('/')) | |
| 347 | 추가: .collect(); | |
| 348 | 추가: let selected = |entry: &&Entry| { | |
| 349 | 추가: matches!(selection, Selection::All) | |
| 350 | 추가: || selected_ids.contains(&entry.id) | |
| 351 | 추가: || entry | |
| 352 | 추가: .name | |
| 353 | 추가: .match_indices('/') | |
| 354 | 추가: .any(|(n, _)| directories.contains(&entry.name[..n])) | |
| 355 | 추가: }; | |
| 356 | 추가: let entries: Vec<_> = self.entries.iter().filter(selected).collect(); | |
| 357 | 추가: usage.estimated_entries = u32::try_from(entries.len()).ok(); | |
| 358 | 추가: usage.estimated_bytes = entries | |
| 359 | 추가: .iter() | |
| 360 | 추가: .try_fold(0u64, |sum, e| sum.checked_add(e.bytes?)); | |
| 361 | 추가: } | |
| 362 | 추가: Start::CreateZip { sources, .. } => { | |
| 363 | 추가: usage.estimated_bytes = sources.iter().try_fold(0u64, |sum, (path, _)| { | |
| 364 | 추가: let m = std::fs::symlink_metadata(path).ok()?; | |
| 365 | 추가: if !m.is_file() { | |
| 366 | 추가: return None; | |
| 367 | 추가: } | |
| 368 | 추가: sum.checked_add(m.len()) | |
| 369 | 추가: }); | |
| 370 | 추가: usage.estimated_entries = sources | |
| 371 | 추가: .iter() | |
| 372 | 추가: .all(|(path, _)| std::fs::symlink_metadata(path).is_ok_and(|m| m.is_file())) | |
| 373 | 추가: .then(|| u32::try_from(sources.len()).ok()) | |
| 374 | 추가: .flatten(); | |
| 375 | 추가: } | |
| 376 | 추가: Start::List { .. } => {} | |
| 377 | 추가: } | |
| 378 | 추가: usage | |
| 379 | 추가: } | |
| 380 | 추가: fn needs_expansion(&self, start: &Start) -> bool { | |
| 381 | 추가: let usage = self.estimate(start); | |
| 382 | 추가: usage | |
| 383 | 추가: .estimated_bytes | |
| 384 | 추가: .is_some_and(|n| n > Limits::default().output) | |
| 385 | 추가: || usage | |
| 386 | 추가: .estimated_entries | |
| 387 | 추가: .is_some_and(|n| n > Limits::default().entries) | |
| 388 | 추가: } | |
| 389 | 추가: pub fn can_retry_expanded(&self) -> bool { | |
| 390 | 추가: !self.busy() && self.retry_start.is_some() && self.close == Close::Open | |
| 391 | 추가: } | |
| 392 | 추가: pub fn retry_expanded(&mut self, factory: &mut dyn Factory) -> bool { | |
| 393 | 추가: if !self.can_retry_expanded() { | |
| 394 | 추가: return false; | |
| 395 | 추가: } | |
| 396 | 추가: let start = self.retry_start.clone().unwrap(); | |
| 397 | 추가: self.begin_with_limits(start, factory, true) | |
| 398 | 추가: } | |
| 399 | 추가: pub fn resource_reply(&mut self, job_id: u64, challenge_id: u64, allow: bool) -> bool { | |
| 400 | 추가: if self.job_id() != Some(job_id) || self.cancellation_requested() { | |
| 401 | 추가: return false; | |
| 402 | 추가: } | |
| 403 | 추가: let Some(question) = self.resource.clone().filter(|q| q.id == challenge_id) else { | |
| 404 | 추가: return false; | |
| 405 | 추가: }; | |
| 406 | 추가: if self | |
| 407 | 추가: .send(Command::ResourceReply { | |
| 408 | 추가: challenge_id, | |
| 409 | 추가: scope: question.scope, | |
| 410 | 추가: allow, | |
| 411 | 추가: }) | |
| 412 | 추가: .is_none() | |
| 413 | 추가: { | |
| 414 | 추가: return false; | |
| 415 | 추가: } | |
| 416 | 추가: if allow { | |
| 417 | 추가: let granted = &mut self.running.as_mut().unwrap().granted; | |
| 418 | 추가: granted.output |= question.scope.output; | |
| 419 | 추가: granted.entries |= question.scope.entries; | |
| 420 | 추가: granted.ratio |= question.scope.ratio; | |
| 421 | 추가: } | |
| 422 | 추가: self.resource = None; | |
| 423 | 추가: true | |
| 424 | 추가: } | |
| 425 | 추가: fn begin_with_limits( | |
| 426 | 추가: &mut self, | |
| 427 | 추가: start: Start, | |
| 428 | 추가: factory: &mut dyn Factory, | |
| 429 | 추가: expanded: bool, | |
| 430 | 추가: ) -> bool { | |
| 298 | 431 | if self.busy() || self.close != Close::Open { |
| 299 | 432 | return false; |
| 300 | 433 | } |
| 434 | 추가: let selectable: BTreeSet<_> = self | |
| 435 | 추가: .entries | |
| 436 | 추가: .iter() | |
| 437 | 추가: .filter(|e| matches!(e.kind, Kind::File | Kind::Directory)) | |
| 438 | 추가: .map(|e| e.id) | |
| 439 | 추가: .collect(); | |
| 301 | 440 | let validation = match &start { |
| 302 | 441 | Start::List { archive } => archive.is_absolute(), |
| 303 | 442 | Start::Extract { |
| @@ -320,12 +459,7 @@ impl Model { | ||
| 320 | 459 | Selection::EntryIds(ids) => { |
| 321 | 460 | !ids.is_empty() |
| 322 | 461 | && ids.iter().collect::<BTreeSet<_>>().len() == ids.len() |
| 323 | 삭제: && ids.iter().all(|id| { | |
| 324 | 삭제: self.entries.iter().any(|e| { | |
| 325 | 삭제: e.id == *id | |
| 326 | 삭제: && matches!(e.kind, Kind::File | Kind::Directory) | |
| 327 | 삭제: }) | |
| 328 | 삭제: }) | |
| 462 | 추가: && ids.iter().all(|id| selectable.contains(id)) | |
| 329 | 463 | } |
| 330 | 464 | } |
| 331 | 465 | } |
| @@ -349,6 +483,7 @@ impl Model { | ||
| 349 | 483 | self.error = Some("작업 ID 한도에 도달했습니다".into()); |
| 350 | 484 | return false; |
| 351 | 485 | }; |
| 486 | 추가: let estimated = self.estimate(&start); | |
| 352 | 487 | let mut connection = match factory.connect(id) { |
| 353 | 488 | Ok(c) => c, |
| 354 | 489 | Err(e) => { |
| @@ -360,7 +495,11 @@ impl Model { | ||
| 360 | 495 | .send(Request { |
| 361 | 496 | job_id: id, |
| 362 | 497 | sequence: 0, |
| 363 | 삭제: command: Command::Start(start.clone()), | |
| 498 | 추가: command: if expanded { | |
| 499 | 추가: Command::StartExpanded(start.clone()) | |
| 500 | 추가: } else { | |
| 501 | 추가: Command::Start(start.clone()) | |
| 502 | 추가: }, | |
| 364 | 503 | }) |
| 365 | 504 | .err(); |
| 366 | 505 | let started = send_error.is_none(); |
| @@ -374,6 +513,8 @@ impl Model { | ||
| 374 | 513 | } |
| 375 | 514 | self.next_id = id; |
| 376 | 515 | self.terminal = None; |
| 516 | 추가: self.retry_start = None; | |
| 517 | 추가: self.resource = None; | |
| 377 | 518 | self.challenge = None; |
| 378 | 519 | self.progress = None; |
| 379 | 520 | self.outputs.clear(); |
| @@ -396,6 +537,10 @@ impl Model { | ||
| 396 | 537 | stderr_eof: false, |
| 397 | 538 | exit: None, |
| 398 | 539 | cancel_sequence: None, |
| 540 | 추가: expanded, | |
| 541 | 추가: granted: ResourceScope::default(), | |
| 542 | 추가: last_challenge: 0, | |
| 543 | 추가: estimated, | |
| 399 | 544 | }); |
| 400 | 545 | started |
| 401 | 546 | } |
| @@ -443,6 +588,7 @@ impl Model { | ||
| 443 | 588 | .is_some() |
| 444 | 589 | { |
| 445 | 590 | self.challenge = None; |
| 591 | 추가: self.resource = None; | |
| 446 | 592 | self.input_error = None; |
| 447 | 593 | true |
| 448 | 594 | } else { |
| @@ -483,6 +629,7 @@ impl Model { | ||
| 483 | 629 | if let Some(seq) = self.send(Command::Cancel) { |
| 484 | 630 | self.running.as_mut().unwrap().cancel_sequence = Some(seq); |
| 485 | 631 | self.challenge = None; |
| 632 | 추가: self.resource = None; | |
| 486 | 633 | self.input_error = None; |
| 487 | 634 | } |
| 488 | 635 | } |
| @@ -564,7 +711,25 @@ impl Model { | ||
| 564 | 711 | self.list_id = None; |
| 565 | 712 | self.selected.clear(); |
| 566 | 713 | } |
| 714 | 추가: self.retry_start = if !run.expanded | |
| 715 | 추가: && run.cancel_sequence.is_none() | |
| 716 | 추가: && self.confirmed | |
| 717 | 추가: && self.terminal.as_ref().is_some_and(|t| { | |
| 718 | 추가: t.outcome == Outcome::Failed | |
| 719 | 추가: && t.error == Some(ErrorCode::Limit) | |
| 720 | 추가: && t.publication == Publication::None | |
| 721 | 추가: && t.created_count == 0 | |
| 722 | 추가: && t.retained_partial_count == 0 | |
| 723 | 추가: && t.cleanup == Cleanup::Complete | |
| 724 | 추가: }) | |
| 725 | 추가: && self.outputs.iter().all(|(_, d)| *d == Disposition::Removed) | |
| 726 | 추가: { | |
| 727 | 추가: Some(run.start.clone()) | |
| 728 | 추가: } else { | |
| 729 | 추가: None | |
| 730 | 추가: }; | |
| 567 | 731 | self.challenge = None; |
| 732 | 추가: self.resource = None; | |
| 568 | 733 | self.input_error = None; |
| 569 | 734 | if matches!(self.close, Close::Waiting | Close::Confirm) { |
| 570 | 735 | self.close = Close::Review; |
| @@ -611,7 +776,12 @@ impl Model { | ||
| 611 | 776 | || run.list_end.is_some() |
| 612 | 777 | || entry.id as usize != run.entries.len() |
| 613 | 778 | || entry.name.len() > 4096 |
| 614 | 삭제: || run.entries.len() >= 100_000 | |
| 779 | 추가: || run.entries.len() | |
| 780 | 추가: >= if run.granted.entries { | |
| 781 | 추가: 200_000 | |
| 782 | 추가: } else { | |
| 783 | 추가: 100_000 | |
| 784 | 추가: } | |
| 615 | 785 | { |
| 616 | 786 | self.error = Some("목록 응답이 유효하지 않습니다".into()); |
| 617 | 787 | } else { |
| @@ -636,12 +806,55 @@ impl Model { | ||
| 636 | 806 | attempt, |
| 637 | 807 | encrypt, |
| 638 | 808 | } => { |
| 639 | 삭제: if self.challenge.is_some() || challenge_id == 0 { | |
| 809 | 추가: if run.cancel_sequence.is_some() { | |
| 810 | 추가: return; | |
| 811 | 추가: } | |
| 812 | 추가: if self.challenge.is_some() | |
| 813 | 추가: || self.resource.is_some() | |
| 814 | 추가: || challenge_id <= run.last_challenge | |
| 815 | 추가: { | |
| 640 | 816 | self.error = Some("암호 요청이 유효하지 않습니다".into()); |
| 641 | 817 | } else { |
| 818 | 추가: run.last_challenge = challenge_id; | |
| 642 | 819 | self.challenge = Some((challenge_id, attempt, encrypt)); |
| 643 | 820 | } |
| 644 | 821 | } |
| 822 | 추가: Event::ResourceRequired(question) => { | |
| 823 | 추가: if run.cancel_sequence.is_some() { | |
| 824 | 추가: return; | |
| 825 | 추가: } | |
| 826 | 추가: let expected = match run.start { | |
| 827 | 추가: Start::List { .. } => ActionKind::List, | |
| 828 | 추가: Start::Extract { .. } => ActionKind::Extract, | |
| 829 | 추가: Start::CreateZip { .. } => ActionKind::CreateZip, | |
| 830 | 추가: }; | |
| 831 | 추가: let hard = Limits { | |
| 832 | 추가: input: u64::MAX, | |
| 833 | 추가: output: 64 * 1024 * 1024 * 1024, | |
| 834 | 추가: entries: 200_000, | |
| 835 | 추가: }; | |
| 836 | 추가: let ceiling = if run.expanded { | |
| 837 | 추가: hard | |
| 838 | 추가: } else { | |
| 839 | 추가: Limits::default() | |
| 840 | 추가: }; | |
| 841 | 추가: if self.challenge.is_some() | |
| 842 | 추가: || self.resource.is_some() | |
| 843 | 추가: || question.id <= run.last_challenge | |
| 844 | 추가: || question.action != expected | |
| 845 | 추가: || !question.scope.any() | |
| 846 | 추가: || question.soft_limits != Limits::default() | |
| 847 | 추가: || question.ceiling != ceiling | |
| 848 | 추가: || (question.scope.output && (!run.expanded || run.granted.output)) | |
| 849 | 추가: || (question.scope.entries && (!run.expanded || run.granted.entries)) | |
| 850 | 추가: || (question.scope.ratio && run.granted.ratio) | |
| 851 | 추가: { | |
| 852 | 추가: self.error = Some("자원 승인 요청이 유효하지 않습니다".into()); | |
| 853 | 추가: } else { | |
| 854 | 추가: run.last_challenge = question.id; | |
| 855 | 추가: self.resource = Some(question); | |
| 856 | 추가: } | |
| 857 | 추가: } | |
| 645 | 858 | Event::Progress { |
| 646 | 859 | stage, |
| 647 | 860 | processed, |
| @@ -653,7 +866,14 @@ impl Model { | ||
| 653 | 866 | disposition, |
| 654 | 867 | .. |
| 655 | 868 | } => { |
| 656 | 삭제: if self.outputs.len() < 100_000 && relative_name.len() <= 4096 { | |
| 869 | 추가: if self.outputs.len() | |
| 870 | 추가: < if run.granted.entries { | |
| 871 | 추가: 200_000 | |
| 872 | 추가: } else { | |
| 873 | 추가: 100_000 | |
| 874 | 추가: } | |
| 875 | 추가: && relative_name.len() <= 4096 | |
| 876 | 추가: { | |
| 657 | 877 | self.outputs.push((relative_name, disposition)); |
| 658 | 878 | } else { |
| 659 | 879 | self.error = Some("출력 보고 한도 초과".into()); |
| @@ -685,6 +905,9 @@ impl Model { | ||
| 685 | 905 | if self.terminal.is_some() { |
| 686 | 906 | return "작업 결과 수신 / 프로세스 종료 확인 중".into(); |
| 687 | 907 | } |
| 908 | 추가: if self.resource.is_some() { | |
| 909 | 추가: return "사용자 허용 대기".into(); | |
| 910 | 추가: } | |
| 688 | 911 | if self.challenge.is_some() { |
| 689 | 912 | return "암호를 입력하세요".into(); |
| 690 | 913 | } |
| @@ -690,3 +690,5 @@ fn cancel_racing_exit_without_terminal_remains_unconfirmed() { | ||
| 690 | 690 | assert!(model.error.is_some()); |
| 691 | 691 | assert_eq!(model.close, Close::Review); |
| 692 | 692 | } |
| 693 | 추가: | |
| 694 | 추가: mod guarded_flows; |
| @@ -0,0 +1,112 @@ | ||
| 1 | 추가: use super::*; | |
| 2 | 추가: use std::collections::VecDeque; | |
| 3 | 추가: struct FirstLimit { | |
| 4 | 추가: first: bool, | |
| 5 | 추가: process: ProcessFactory, | |
| 6 | 추가: } | |
| 7 | 추가: struct Failed { | |
| 8 | 추가: job: u64, | |
| 9 | 추가: events: VecDeque<HostEvent>, | |
| 10 | 추가: } | |
| 11 | 추가: impl Connection for Failed { | |
| 12 | 추가: fn send(&mut self, request: Request) -> Result<(), String> { | |
| 13 | 추가: assert!(matches!(request.command, Command::Start(_))); | |
| 14 | 추가: self.events.extend([ | |
| 15 | 추가: HostEvent::Frame { | |
| 16 | 추가: job_id: self.job, | |
| 17 | 추가: sequence: 0, | |
| 18 | 추가: event: Event::Accepted { encryption: true }, | |
| 19 | 추가: }, | |
| 20 | 추가: HostEvent::Frame { | |
| 21 | 추가: job_id: self.job, | |
| 22 | 추가: sequence: 1, | |
| 23 | 추가: event: Event::Terminal(Terminal { | |
| 24 | 추가: outcome: Outcome::Failed, | |
| 25 | 추가: error: Some(ErrorCode::Limit), | |
| 26 | 추가: publication: Publication::None, | |
| 27 | 추가: created_count: 0, | |
| 28 | 추가: retained_partial_count: 0, | |
| 29 | 추가: durability: Durability::NotApplicable, | |
| 30 | 추가: cleanup: Cleanup::Complete, | |
| 31 | 추가: }), | |
| 32 | 추가: }, | |
| 33 | 추가: HostEvent::StdoutEof, | |
| 34 | 추가: HostEvent::StderrEof, | |
| 35 | 추가: HostEvent::Exited { success: true }, | |
| 36 | 추가: ]); | |
| 37 | 추가: Ok(()) | |
| 38 | 추가: } | |
| 39 | 추가: fn poll(&mut self) -> Option<HostEvent> { | |
| 40 | 추가: self.events.pop_front() | |
| 41 | 추가: } | |
| 42 | 추가: } | |
| 43 | 추가: impl Factory for FirstLimit { | |
| 44 | 추가: fn connect(&mut self, job: u64) -> Result<Box<dyn Connection>, String> { | |
| 45 | 추가: if self.first { | |
| 46 | 추가: self.first = false; | |
| 47 | 추가: Ok(Box::new(Failed { | |
| 48 | 추가: job, | |
| 49 | 추가: events: VecDeque::new(), | |
| 50 | 추가: })) | |
| 51 | 추가: } else { | |
| 52 | 추가: self.process.connect(job) | |
| 53 | 추가: } | |
| 54 | 추가: } | |
| 55 | 추가: } | |
| 56 | 추가: #[test] | |
| 57 | 추가: fn model_retry_uses_real_guarded_codec_and_requires_a_new_job_approval() { | |
| 58 | 추가: for mode in 0..3 { | |
| 59 | 추가: let scratch = Scratch::new(); | |
| 60 | 추가: let archive = scratch.path("sample.zip"); | |
| 61 | 추가: fs::write(&archive, include_bytes!("fixtures/sample.zip")).unwrap(); | |
| 62 | 추가: let mut factory = FirstLimit { | |
| 63 | 추가: first: true, | |
| 64 | 추가: process: ProcessFactory::new(binary("zipelo-archive-worker")), | |
| 65 | 추가: }; | |
| 66 | 추가: let mut model = Model::default(); | |
| 67 | 추가: assert!(model.begin(Start::List { archive }, &mut factory)); | |
| 68 | 추가: let first_job = model.job_id().unwrap(); | |
| 69 | 추가: wait(&mut model); | |
| 70 | 추가: assert!(model.can_retry_expanded()); | |
| 71 | 추가: assert!(model.retry_expanded(&mut factory)); | |
| 72 | 추가: let job = model.job_id().unwrap(); | |
| 73 | 추가: assert_ne!(first_job, job); | |
| 74 | 추가: let deadline = Instant::now() + Duration::from_secs(10); | |
| 75 | 추가: while model.resource.is_none() { | |
| 76 | 추가: model.poll(); | |
| 77 | 추가: assert!(model.error.is_none(), "{:?}", model.error); | |
| 78 | 추가: assert!(Instant::now() < deadline); | |
| 79 | 추가: std::thread::sleep(Duration::from_millis(1)); | |
| 80 | 추가: } | |
| 81 | 추가: let q = model.resource.clone().unwrap(); | |
| 82 | 추가: assert_eq!( | |
| 83 | 추가: q.scope, | |
| 84 | 추가: ResourceScope { | |
| 85 | 추가: output: true, | |
| 86 | 추가: entries: true, | |
| 87 | 추가: ratio: false | |
| 88 | 추가: } | |
| 89 | 추가: ); | |
| 90 | 추가: assert_eq!(q.usage.actual_bytes, None); | |
| 91 | 추가: assert!(q.usage.available_bytes.is_some()); | |
| 92 | 추가: assert!(model.entries.is_empty()); | |
| 93 | 추가: assert!(!model.resource_reply(first_job, q.id, true)); | |
| 94 | 추가: if mode == 2 { | |
| 95 | 추가: model.cancel(); | |
| 96 | 추가: } else { | |
| 97 | 추가: assert!(model.resource_reply(job, q.id, mode == 0)); | |
| 98 | 추가: } | |
| 99 | 추가: wait(&mut model); | |
| 100 | 추가: assert!(model.confirmed, "{:?}", model.error); | |
| 101 | 추가: assert_eq!( | |
| 102 | 추가: model.terminal.as_ref().unwrap().outcome, | |
| 103 | 추가: if mode == 0 { | |
| 104 | 추가: Outcome::Completed | |
| 105 | 추가: } else { | |
| 106 | 추가: Outcome::Cancelled | |
| 107 | 추가: } | |
| 108 | 추가: ); | |
| 109 | 추가: assert_eq!(model.list_id.is_some(), mode == 0); | |
| 110 | 추가: assert!(model.resource.is_none()); | |
| 111 | 추가: } | |
| 112 | 추가: } |
| @@ -181,7 +181,7 @@ impl Factory for CaptureFactory { | ||
| 181 | 181 | impl Connection for CaptureConnection { |
| 182 | 182 | fn send(&mut self, request: Request) -> Result<(), String> { |
| 183 | 183 | match request.command { |
| 184 | 삭제: Command::Start(start) => { | |
| 184 | 추가: Command::Start(start) | Command::StartExpanded(start) => { | |
| 185 | 185 | self.event(Event::Accepted { encryption: true }); |
| 186 | 186 | match start { |
| 187 | 187 | Start::List { .. } => { |
| @@ -247,6 +247,7 @@ impl Connection for CaptureConnection { | ||
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | Command::Password { .. } => self.finish(false), |
| 250 | 추가: Command::ResourceReply { .. } => {} | |
| 250 | 251 | Command::Cancel => { |
| 251 | 252 | self.event(Event::CancelAck { |
| 252 | 253 | request_sequence: request.sequence, |
| @@ -6,6 +6,8 @@ pub struct State { | ||
| 6 | 6 | pub requests: Vec<(u64, &'static str)>, |
| 7 | 7 | pub starts: Vec<Start>, |
| 8 | 8 | pub password_seen: bool, |
| 9 | 추가: pub expanded: bool, | |
| 10 | 추가: pub resources: Vec<(u64, ResourceScope, bool)>, | |
| 9 | 11 | /// 마지막으로 받은 암호 원문. 화면에서 입력한 암호가 그대로 전달됐는지 확인할 때 씀. |
| 10 | 12 | pub password: Vec<u8>, |
| 11 | 13 | pub job: u64, |
| @@ -130,8 +132,11 @@ impl Connection for FakeConnection { | ||
| 130 | 132 | fn send(&mut self, request: Request) -> Result<(), String> { |
| 131 | 133 | let mut s = self.state.borrow_mut(); |
| 132 | 134 | assert_eq!(s.job, request.job_id); |
| 135 | 추가: if matches!(&request.command, Command::StartExpanded(_)) { | |
| 136 | 추가: s.expanded = true; | |
| 137 | 추가: } | |
| 133 | 138 | match request.command { |
| 134 | 삭제: Command::Start(start) => { | |
| 139 | 추가: Command::Start(start) | Command::StartExpanded(start) => { | |
| 135 | 140 | if let Start::Extract { |
| 136 | 141 | list_id, |
| 137 | 142 | gzip_output_name, |
| @@ -184,6 +189,13 @@ impl Connection for FakeConnection { | ||
| 184 | 189 | s.complete_action(); |
| 185 | 190 | } |
| 186 | 191 | } |
| 192 | 추가: Command::ResourceReply { | |
| 193 | 추가: challenge_id, | |
| 194 | 추가: scope, | |
| 195 | 추가: allow, | |
| 196 | 추가: } => { | |
| 197 | 추가: s.resources.push((challenge_id, scope, allow)); | |
| 198 | 추가: } | |
| 187 | 199 | Command::Cancel => { |
| 188 | 200 | s.requests.push((request.sequence, "cancel")); |
| 189 | 201 | if !s.manual { |
| @@ -0,0 +1,267 @@ | ||
| 1 | 추가: use super::*; | |
| 2 | 추가: | |
| 3 | 추가: fn waiting() -> (Model, FakeFactory) { | |
| 4 | 추가: let mut f = FakeFactory::manual(); | |
| 5 | 추가: let mut m = Model::default(); | |
| 6 | 추가: assert!(m.begin( | |
| 7 | 추가: Start::List { | |
| 8 | 추가: archive: path("large.zip") | |
| 9 | 추가: }, | |
| 10 | 추가: &mut f | |
| 11 | 추가: )); | |
| 12 | 추가: f.state | |
| 13 | 추가: .borrow_mut() | |
| 14 | 추가: .frame(Event::Accepted { encryption: true }); | |
| 15 | 추가: for _ in 0..4 { | |
| 16 | 추가: m.poll(); | |
| 17 | 추가: } | |
| 18 | 추가: (m, f) | |
| 19 | 추가: } | |
| 20 | 추가: fn question(id: u64) -> ResourceChallenge { | |
| 21 | 추가: ResourceChallenge { | |
| 22 | 추가: id, | |
| 23 | 추가: action: ActionKind::List, | |
| 24 | 추가: scope: ResourceScope { | |
| 25 | 추가: ratio: true, | |
| 26 | 추가: ..Default::default() | |
| 27 | 추가: }, | |
| 28 | 추가: usage: ResourceUsage::default(), | |
| 29 | 추가: soft_limits: Limits::default(), | |
| 30 | 추가: ceiling: Limits::default(), | |
| 31 | 추가: } | |
| 32 | 추가: } | |
| 33 | 추가: fn receive(m: &mut Model, f: &FakeFactory, event: Event) { | |
| 34 | 추가: f.state.borrow_mut().frame(event); | |
| 35 | 추가: for _ in 0..4 { | |
| 36 | 추가: m.poll(); | |
| 37 | 추가: } | |
| 38 | 추가: } | |
| 39 | 추가: fn fail( | |
| 40 | 추가: m: &mut Model, | |
| 41 | 추가: f: &FakeFactory, | |
| 42 | 추가: publication: Publication, | |
| 43 | 추가: created: u64, | |
| 44 | 추가: partial: u64, | |
| 45 | 추가: cleanup: Cleanup, | |
| 46 | 추가: ) { | |
| 47 | 추가: let mut s = f.state.borrow_mut(); | |
| 48 | 추가: s.frame(Event::Terminal(Terminal { | |
| 49 | 추가: outcome: Outcome::Failed, | |
| 50 | 추가: error: Some(ErrorCode::Limit), | |
| 51 | 추가: publication, | |
| 52 | 추가: created_count: created, | |
| 53 | 추가: retained_partial_count: partial, | |
| 54 | 추가: durability: Durability::NotApplicable, | |
| 55 | 추가: cleanup, | |
| 56 | 추가: })); | |
| 57 | 추가: s.queue.extend([ | |
| 58 | 추가: HostEvent::StdoutEof, | |
| 59 | 추가: HostEvent::StderrEof, | |
| 60 | 추가: HostEvent::Exited { success: true }, | |
| 61 | 추가: ]); | |
| 62 | 추가: drop(s); | |
| 63 | 추가: pump(m); | |
| 64 | 추가: } | |
| 65 | 추가: #[test] | |
| 66 | 추가: fn reply_is_bound_to_job_question_scope_and_once_only() { | |
| 67 | 추가: let (mut m, f) = waiting(); | |
| 68 | 추가: receive(&mut m, &f, Event::ResourceRequired(question(1))); | |
| 69 | 추가: assert!(!m.resource_reply(99, 1, true)); | |
| 70 | 추가: assert!(!m.resource_reply(m.job_id().unwrap(), 2, true)); | |
| 71 | 추가: assert!(m.resource_reply(m.job_id().unwrap(), 1, true)); | |
| 72 | 추가: assert!(!m.resource_reply(m.job_id().unwrap(), 1, true)); | |
| 73 | 추가: assert_eq!(f.state.borrow().resources, [(1, question(1).scope, true)]); | |
| 74 | 추가: } | |
| 75 | 추가: #[test] | |
| 76 | 추가: fn cancel_during_question_never_grants_and_clears_prompt() { | |
| 77 | 추가: let (mut m, f) = waiting(); | |
| 78 | 추가: receive(&mut m, &f, Event::ResourceRequired(question(1))); | |
| 79 | 추가: let job = m.job_id().unwrap(); | |
| 80 | 추가: m.cancel(); | |
| 81 | 추가: assert!(m.resource.is_none()); | |
| 82 | 추가: assert!(!m.resource_reply(job, 1, true)); | |
| 83 | 추가: f.state | |
| 84 | 추가: .borrow_mut() | |
| 85 | 추가: .finish(Outcome::Cancelled, Publication::None); | |
| 86 | 추가: pump(&mut m); | |
| 87 | 추가: assert!(f.state.borrow().resources.is_empty()); | |
| 88 | 추가: assert!(m.confirmed); | |
| 89 | 추가: } | |
| 90 | 추가: #[test] | |
| 91 | 추가: fn queued_question_after_cancel_does_not_turn_cancel_into_transport_failure() { | |
| 92 | 추가: let (mut m, f) = waiting(); | |
| 93 | 추가: m.cancel(); | |
| 94 | 추가: receive(&mut m, &f, Event::ResourceRequired(question(1))); | |
| 95 | 추가: assert!(m.resource.is_none()); | |
| 96 | 추가: assert!(m.error.is_none()); | |
| 97 | 추가: } | |
| 98 | 추가: #[test] | |
| 99 | 추가: fn wrong_action_limits_empty_scope_and_overlapping_questions_are_rejected() { | |
| 100 | 추가: for mode in 0..6 { | |
| 101 | 추가: let (mut m, f) = waiting(); | |
| 102 | 추가: let mut q = question(1); | |
| 103 | 추가: match mode { | |
| 104 | 추가: 0 => q.action = ActionKind::Extract, | |
| 105 | 추가: 1 => q.ceiling.output += 1, | |
| 106 | 추가: 2 => q.scope = ResourceScope::default(), | |
| 107 | 추가: 3 => q.id = 0, | |
| 108 | 추가: 4 => receive( | |
| 109 | 추가: &mut m, | |
| 110 | 추가: &f, | |
| 111 | 추가: Event::PasswordRequired { | |
| 112 | 추가: challenge_id: 1, | |
| 113 | 추가: attempt: 1, | |
| 114 | 추가: encrypt: false, | |
| 115 | 추가: }, | |
| 116 | 추가: ), | |
| 117 | 추가: _ => receive(&mut m, &f, Event::ResourceRequired(q.clone())), | |
| 118 | 추가: } | |
| 119 | 추가: receive(&mut m, &f, Event::ResourceRequired(q)); | |
| 120 | 추가: assert!(m.error.is_some(), "{mode}"); | |
| 121 | 추가: } | |
| 122 | 추가: } | |
| 123 | 추가: #[test] | |
| 124 | 추가: fn old_challenge_and_repeated_scope_are_rejected_after_reply() { | |
| 125 | 추가: for reused_id in [true, false] { | |
| 126 | 추가: let (mut m, f) = waiting(); | |
| 127 | 추가: receive(&mut m, &f, Event::ResourceRequired(question(1))); | |
| 128 | 추가: assert!(m.resource_reply(m.job_id().unwrap(), 1, true)); | |
| 129 | 추가: receive( | |
| 130 | 추가: &mut m, | |
| 131 | 추가: &f, | |
| 132 | 추가: Event::ResourceRequired(question(if reused_id { 1 } else { 2 })), | |
| 133 | 추가: ); | |
| 134 | 추가: assert!(m.error.is_some()); | |
| 135 | 추가: } | |
| 136 | 추가: } | |
| 137 | 추가: #[test] | |
| 138 | 추가: fn only_confirmed_clean_empty_failure_offers_expanded_retry_once() { | |
| 139 | 추가: for (publication, count, partial, cleanup, retry) in [ | |
| 140 | 추가: (Publication::None, 0, 0, Cleanup::Complete, true), | |
| 141 | 추가: (Publication::None, 1, 0, Cleanup::Complete, false), | |
| 142 | 추가: (Publication::Partial, 1, 0, Cleanup::Complete, false), | |
| 143 | 추가: (Publication::Uncertain, 0, 0, Cleanup::Complete, false), | |
| 144 | 추가: (Publication::None, 0, 1, Cleanup::Complete, false), | |
| 145 | 추가: (Publication::None, 0, 0, Cleanup::Unconfirmed, false), | |
| 146 | 추가: ] { | |
| 147 | 추가: let (mut m, mut f) = waiting(); | |
| 148 | 추가: fail(&mut m, &f, publication, count, partial, cleanup); | |
| 149 | 추가: assert_eq!(m.can_retry_expanded(), retry); | |
| 150 | 추가: assert_eq!(m.retry_expanded(&mut f), retry); | |
| 151 | 추가: if retry { | |
| 152 | 추가: assert!(f.state.borrow().expanded); | |
| 153 | 추가: receive(&mut m, &f, Event::Accepted { encryption: true }); | |
| 154 | 추가: fail(&mut m, &f, Publication::None, 0, 0, Cleanup::Complete); | |
| 155 | 추가: assert!(!m.can_retry_expanded()); | |
| 156 | 추가: } | |
| 157 | 추가: } | |
| 158 | 추가: } | |
| 159 | 추가: #[test] | |
| 160 | 추가: fn known_extract_size_requests_expansion_before_processing_and_estimates_unknown_separately() { | |
| 161 | 추가: let mut m = Model::default(); | |
| 162 | 추가: let mut f = FakeFactory::default(); | |
| 163 | 추가: list(&mut m, &mut f); | |
| 164 | 추가: m.entries[0].bytes = Some(Limits::default().output + 1); | |
| 165 | 추가: f.state.borrow_mut().manual = true; | |
| 166 | 추가: assert!(m.extract(path("out"), false, None, &mut f)); | |
| 167 | 추가: assert!(f.state.borrow().expanded); | |
| 168 | 추가: assert_eq!( | |
| 169 | 추가: m.estimated_usage().estimated_bytes, | |
| 170 | 추가: Some(Limits::default().output + 1) | |
| 171 | 추가: ); | |
| 172 | 추가: assert_eq!(m.estimated_usage().actual_bytes, None); | |
| 173 | 추가: } | |
| 174 | 추가: #[test] | |
| 175 | 추가: fn entries_over_one_hundred_thousand_are_accepted_only_after_entry_approval() { | |
| 176 | 추가: for approved in [false, true] { | |
| 177 | 추가: let (mut m, f) = waiting(); | |
| 178 | 추가: if approved { | |
| 179 | 추가: fail(&mut m, &f, Publication::None, 0, 0, Cleanup::Complete); | |
| 180 | 추가: let mut factory = f.clone(); | |
| 181 | 추가: assert!(m.retry_expanded(&mut factory)); | |
| 182 | 추가: receive(&mut m, &f, Event::Accepted { encryption: true }); | |
| 183 | 추가: let mut q = question(1); | |
| 184 | 추가: q.scope = ResourceScope { | |
| 185 | 추가: output: true, | |
| 186 | 추가: entries: true, | |
| 187 | 추가: ratio: false, | |
| 188 | 추가: }; | |
| 189 | 추가: q.ceiling = Limits { | |
| 190 | 추가: input: u64::MAX, | |
| 191 | 추가: output: 64 * 1024 * 1024 * 1024, | |
| 192 | 추가: entries: 200_000, | |
| 193 | 추가: }; | |
| 194 | 추가: receive(&mut m, &f, Event::ResourceRequired(q)); | |
| 195 | 추가: assert!(m.resource_reply(m.job_id().unwrap(), 1, true)); | |
| 196 | 추가: } | |
| 197 | 추가: let cap = if approved { 200_000 } else { 100_000 }; | |
| 198 | 추가: for id in 0..=cap { | |
| 199 | 추가: assert!(m.error.is_none(), "{id}"); | |
| 200 | 추가: receive( | |
| 201 | 추가: &mut m, | |
| 202 | 추가: &f, | |
| 203 | 추가: Event::Entry(Entry { | |
| 204 | 추가: id, | |
| 205 | 추가: name: format!("{id}"), | |
| 206 | 추가: kind: Kind::File, | |
| 207 | 추가: bytes: Some(0), | |
| 208 | 추가: packed: Some(0), | |
| 209 | 추가: encrypted: false, | |
| 210 | 추가: }), | |
| 211 | 추가: ); | |
| 212 | 추가: } | |
| 213 | 추가: assert!(m.error.is_some()); | |
| 214 | 추가: } | |
| 215 | 추가: } | |
| 216 | 추가: | |
| 217 | 추가: #[test] | |
| 218 | 추가: fn output_history_ceiling_expands_only_after_entry_permission() { | |
| 219 | 추가: for approved in [false, true] { | |
| 220 | 추가: let mut m = Model::default(); | |
| 221 | 추가: let mut f = FakeFactory::manual(); | |
| 222 | 추가: assert!(m.begin( | |
| 223 | 추가: Start::CreateZip { | |
| 224 | 추가: sources: vec![(path("source"), "source".into())], | |
| 225 | 추가: output_file: path("new.zip"), | |
| 226 | 추가: method: Method::Store, | |
| 227 | 추가: aes256: false | |
| 228 | 추가: }, | |
| 229 | 추가: &mut f | |
| 230 | 추가: )); | |
| 231 | 추가: receive(&mut m, &f, Event::Accepted { encryption: true }); | |
| 232 | 추가: if approved { | |
| 233 | 추가: fail(&mut m, &f, Publication::None, 0, 0, Cleanup::Complete); | |
| 234 | 추가: assert!(m.retry_expanded(&mut f)); | |
| 235 | 추가: receive(&mut m, &f, Event::Accepted { encryption: true }); | |
| 236 | 추가: let mut q = question(1); | |
| 237 | 추가: q.action = ActionKind::CreateZip; | |
| 238 | 추가: q.scope = ResourceScope { | |
| 239 | 추가: output: true, | |
| 240 | 추가: entries: true, | |
| 241 | 추가: ratio: false, | |
| 242 | 추가: }; | |
| 243 | 추가: q.ceiling = Limits { | |
| 244 | 추가: input: u64::MAX, | |
| 245 | 추가: output: 64 * 1024 * 1024 * 1024, | |
| 246 | 추가: entries: 200_000, | |
| 247 | 추가: }; | |
| 248 | 추가: receive(&mut m, &f, Event::ResourceRequired(q)); | |
| 249 | 추가: assert!(m.resource_reply(m.job_id().unwrap(), 1, true)); | |
| 250 | 추가: } | |
| 251 | 추가: let cap = if approved { 200_000 } else { 100_000 }; | |
| 252 | 추가: for n in 0..=cap { | |
| 253 | 추가: assert!(m.error.is_none(), "{n}"); | |
| 254 | 추가: receive( | |
| 255 | 추가: &mut m, | |
| 256 | 추가: &f, | |
| 257 | 추가: Event::Output { | |
| 258 | 추가: entry_id: None, | |
| 259 | 추가: relative_name: format!("{n}"), | |
| 260 | 추가: disposition: Disposition::Created, | |
| 261 | 추가: }, | |
| 262 | 추가: ); | |
| 263 | 추가: } | |
| 264 | 추가: assert_eq!(m.outputs.len(), cap); | |
| 265 | 추가: assert!(m.error.is_some()); | |
| 266 | 추가: } | |
| 267 | 추가: } |
| @@ -870,3 +870,5 @@ fn password_validation_and_retry_do_not_erase_transport_failure() { | ||
| 870 | 870 | mod presentation; |
| 871 | 871 | |
| 872 | 872 | mod windows_paths; |
| 873 | 추가: | |
| 874 | 추가: mod guarded; |
| @@ -96,6 +96,10 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() { | ||
| 96 | 96 | ); |
| 97 | 97 | assert!(app.model.input_error.is_none(), "{}", scenario.name); |
| 98 | 98 | let expected = match scenario.name { |
| 99 | 추가: "resource-approval" => "큰 작업을 허용할까요?", | |
| 100 | 추가: "resource-ratio" => "압축률이 매우 높습니다", | |
| 101 | 추가: "resource-retry" => "한도를 늘려 다시 시도", | |
| 102 | 추가: "resource-partial" => "저장 위치를 확인하세요", | |
| 99 | 103 | "empty" => "TAR.BZ2, TAR.XZ", |
| 100 | 104 | "tar-bz2" | "tar-xz" => "읽어주세요.txt", |
| 101 | 105 | "folder-empty" => "이 폴더는 비어 있습니다", |
| @@ -197,3 +201,111 @@ fn preview_ignores_password_submission() { | ||
| 197 | 201 | assert_eq!(preview.0.model.challenge, Some((17, 1, false))); |
| 198 | 202 | assert!(preview.0.model.busy()); |
| 199 | 203 | } |
| 204 | 추가: | |
| 205 | 추가: fn resource_frame( | |
| 206 | 추가: app: &mut zipelo_ui_memory_app::archive_screen::ArchiveApp, | |
| 207 | 추가: ctx: &egui::Context, | |
| 208 | 추가: events: Vec<egui::Event>, | |
| 209 | 추가: ) -> Vec<egui::epaint::ClippedShape> { | |
| 210 | 추가: let mut out = ctx.run_ui( | |
| 211 | 추가: egui::RawInput { | |
| 212 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 213 | 추가: egui::Pos2::ZERO, | |
| 214 | 추가: egui::vec2(760.0, 540.0), | |
| 215 | 추가: )), | |
| 216 | 추가: events, | |
| 217 | 추가: ..Default::default() | |
| 218 | 추가: }, | |
| 219 | 추가: |ui| app.show(ui), | |
| 220 | 추가: ); | |
| 221 | 추가: out.textures_delta.clear(); | |
| 222 | 추가: out.shapes | |
| 223 | 추가: } | |
| 224 | 추가: fn find_resource_action(shapes: &[egui::epaint::ClippedShape], label: &str) -> egui::Pos2 { | |
| 225 | 추가: fn find(s: &egui::Shape, label: &str) -> Option<egui::Pos2> { | |
| 226 | 추가: match s { | |
| 227 | 추가: egui::Shape::Text(t) if t.galley.text() == label => { | |
| 228 | 추가: Some(t.pos + t.galley.rect.size() / 2.0) | |
| 229 | 추가: } | |
| 230 | 추가: egui::Shape::Vec(shapes) => shapes.iter().find_map(|s| find(s, label)), | |
| 231 | 추가: _ => None, | |
| 232 | 추가: } | |
| 233 | 추가: } | |
| 234 | 추가: shapes.iter().find_map(|s| find(&s.shape, label)).unwrap() | |
| 235 | 추가: } | |
| 236 | 추가: #[test] | |
| 237 | 추가: fn resource_dialog_requires_explicit_click_and_escape_cancels() { | |
| 238 | 추가: for allow in [false, true] { | |
| 239 | 추가: let ctx = egui::Context::default(); | |
| 240 | 추가: let mut app = scenarios::parse("resource-ratio").unwrap().build(); | |
| 241 | 추가: let mut shapes = Vec::new(); | |
| 242 | 추가: for _ in 0..3 { | |
| 243 | 추가: shapes = resource_frame(&mut app, &ctx, vec![]); | |
| 244 | 추가: } | |
| 245 | 추가: assert!(text(&shapes).contains("미확인")); | |
| 246 | 추가: resource_frame( | |
| 247 | 추가: &mut app, | |
| 248 | 추가: &ctx, | |
| 249 | 추가: vec![egui::Event::Key { | |
| 250 | 추가: key: egui::Key::Enter, | |
| 251 | 추가: physical_key: None, | |
| 252 | 추가: pressed: true, | |
| 253 | 추가: repeat: false, | |
| 254 | 추가: modifiers: Default::default(), | |
| 255 | 추가: }], | |
| 256 | 추가: ); | |
| 257 | 추가: assert!(app.model.resource.is_some()); | |
| 258 | 추가: if allow { | |
| 259 | 추가: let point = find_resource_action(&shapes, "이 작업 허용"); | |
| 260 | 추가: resource_frame( | |
| 261 | 추가: &mut app, | |
| 262 | 추가: &ctx, | |
| 263 | 추가: vec![ | |
| 264 | 추가: egui::Event::PointerMoved(point), | |
| 265 | 추가: egui::Event::PointerButton { | |
| 266 | 추가: pos: point, | |
| 267 | 추가: button: egui::PointerButton::Primary, | |
| 268 | 추가: pressed: true, | |
| 269 | 추가: modifiers: Default::default(), | |
| 270 | 추가: }, | |
| 271 | 추가: ], | |
| 272 | 추가: ); | |
| 273 | 추가: resource_frame( | |
| 274 | 추가: &mut app, | |
| 275 | 추가: &ctx, | |
| 276 | 추가: vec![egui::Event::PointerButton { | |
| 277 | 추가: pos: point, | |
| 278 | 추가: button: egui::PointerButton::Primary, | |
| 279 | 추가: pressed: false, | |
| 280 | 추가: modifiers: Default::default(), | |
| 281 | 추가: }], | |
| 282 | 추가: ); | |
| 283 | 추가: assert!(!app.model.cancellation_requested()); | |
| 284 | 추가: } else { | |
| 285 | 추가: resource_frame( | |
| 286 | 추가: &mut app, | |
| 287 | 추가: &ctx, | |
| 288 | 추가: vec![egui::Event::Key { | |
| 289 | 추가: key: egui::Key::Escape, | |
| 290 | 추가: physical_key: None, | |
| 291 | 추가: pressed: true, | |
| 292 | 추가: repeat: false, | |
| 293 | 추가: modifiers: Default::default(), | |
| 294 | 추가: }], | |
| 295 | 추가: ); | |
| 296 | 추가: assert!(app.model.cancellation_requested()); | |
| 297 | 추가: } | |
| 298 | 추가: assert!(app.model.resource.is_none()); | |
| 299 | 추가: } | |
| 300 | 추가: } | |
| 301 | 추가: #[test] | |
| 302 | 추가: fn partial_limit_result_never_offers_expanded_retry() { | |
| 303 | 추가: let ctx = egui::Context::default(); | |
| 304 | 추가: let mut app = scenarios::parse("resource-partial").unwrap().build(); | |
| 305 | 추가: let mut shapes = Vec::new(); | |
| 306 | 추가: for _ in 0..3 { | |
| 307 | 추가: shapes = resource_frame(&mut app, &ctx, vec![]); | |
| 308 | 추가: } | |
| 309 | 추가: assert!(!text(&shapes).contains("한도를 늘려 다시 시도")); | |
| 310 | 추가: assert!(text(&shapes).contains("풀린 자료")); | |
| 311 | 추가: } |
| @@ -21,6 +21,10 @@ macro_rules! catalog { | ||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | catalog! { |
| 24 | 추가: "resource-approval" => "처리 전 큰 작업 승인", | |
| 25 | 추가: "resource-ratio" => "고압축 작업 경고와 미확인 값", | |
| 26 | 추가: "resource-retry" => "출력 없는 한도 실패 후 확대 재시도", | |
| 27 | 추가: "resource-partial" => "일부 출력 후 한도 중단", | |
| 24 | 28 | "empty" => "빈 첫 화면", |
| 25 | 29 | "archive" => "폴더와 파일이 있는 압축파일", |
| 26 | 30 | "tar-bz2" => "TAR.BZ2 목록과 자동 해제 폴더", |
| @@ -285,11 +289,71 @@ impl Scenario { | ||
| 285 | 289 | "사진/풍경.jpg".into(), |
| 286 | 290 | ]) |
| 287 | 291 | }); |
| 292 | 추가: if self.name == "resource-approval" { | |
| 293 | 추가: app.model.entries[1].bytes = Some(17 * 1024 * 1024 * 1024); | |
| 294 | 추가: } | |
| 288 | 295 | assert!(app.start(request)); |
| 289 | 296 | { |
| 290 | 297 | let mut state = state.borrow_mut(); |
| 291 | 298 | state.frame(Event::Accepted { encryption: true }); |
| 292 | 299 | match self.name { |
| 300 | 추가: "resource-approval" | "resource-ratio" => { | |
| 301 | 추가: let expanded = self.name == "resource-approval"; | |
| 302 | 추가: state.frame(Event::ResourceRequired(ResourceChallenge { | |
| 303 | 추가: id: 1, | |
| 304 | 추가: action: ActionKind::Extract, | |
| 305 | 추가: scope: ResourceScope { | |
| 306 | 추가: output: expanded, | |
| 307 | 추가: entries: expanded, | |
| 308 | 추가: ratio: !expanded, | |
| 309 | 추가: }, | |
| 310 | 추가: usage: ResourceUsage { | |
| 311 | 추가: available_bytes: Some(90 * 1024 * 1024 * 1024), | |
| 312 | 추가: actual_bytes: (!expanded).then_some(300 * 1024 * 1024), | |
| 313 | 추가: ratio_output_bytes: (!expanded).then_some(300 * 1024 * 1024), | |
| 314 | 추가: compressed_bytes: (!expanded).then_some(4096), | |
| 315 | 추가: ..ResourceUsage::default() | |
| 316 | 추가: }, | |
| 317 | 추가: soft_limits: Limits::default(), | |
| 318 | 추가: ceiling: if expanded { | |
| 319 | 추가: Limits { | |
| 320 | 추가: input: u64::MAX, | |
| 321 | 추가: output: 64 * 1024 * 1024 * 1024, | |
| 322 | 추가: entries: 200_000, | |
| 323 | 추가: } | |
| 324 | 추가: } else { | |
| 325 | 추가: Limits::default() | |
| 326 | 추가: }, | |
| 327 | 추가: })); | |
| 328 | 추가: } | |
| 329 | 추가: "resource-retry" | "resource-partial" => { | |
| 330 | 추가: let partial = self.name == "resource-partial"; | |
| 331 | 추가: if partial { | |
| 332 | 추가: state.frame(Event::Output { | |
| 333 | 추가: entry_id: Some(1), | |
| 334 | 추가: relative_name: "읽어주세요.txt".into(), | |
| 335 | 추가: disposition: Disposition::Created, | |
| 336 | 추가: }); | |
| 337 | 추가: } | |
| 338 | 추가: state.frame(Event::Terminal(Terminal { | |
| 339 | 추가: outcome: Outcome::Failed, | |
| 340 | 추가: error: Some(ErrorCode::Limit), | |
| 341 | 추가: publication: if partial { | |
| 342 | 추가: Publication::Partial | |
| 343 | 추가: } else { | |
| 344 | 추가: Publication::None | |
| 345 | 추가: }, | |
| 346 | 추가: created_count: u64::from(partial), | |
| 347 | 추가: retained_partial_count: 0, | |
| 348 | 추가: durability: Durability::Synced, | |
| 349 | 추가: cleanup: Cleanup::Complete, | |
| 350 | 추가: })); | |
| 351 | 추가: state.queue.extend([ | |
| 352 | 추가: HostEvent::StdoutEof, | |
| 353 | 추가: HostEvent::StderrEof, | |
| 354 | 추가: HostEvent::Exited { success: true }, | |
| 355 | 추가: ]); | |
| 356 | 추가: } | |
| 293 | 357 | "password" | "password-retry" | "password-create" => { |
| 294 | 358 | state.frame(Event::PasswordRequired { |
| 295 | 359 | challenge_id: 17, |
| @@ -598,3 +598,105 @@ fn unanswered_close_confirmation_does_not_close_when_work_finishes() { | ||
| 598 | 598 | policy_render(&ctx, &mut app, vec![]); |
| 599 | 599 | assert_eq!(app.model.close, Close::Allowed); |
| 600 | 600 | } |
| 601 | 추가: | |
| 602 | 추가: #[test] | |
| 603 | 추가: fn resource_prompt_is_not_covered_by_separate_work_window() { | |
| 604 | 추가: let factory = FakeFactory::manual(); | |
| 605 | 추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), None, false); | |
| 606 | 추가: assert!(app.model.begin( | |
| 607 | 추가: Start::List { | |
| 608 | 추가: archive: std::env::current_dir().unwrap().join("large.zip") | |
| 609 | 추가: }, | |
| 610 | 추가: &mut factory.clone() | |
| 611 | 추가: )); | |
| 612 | 추가: { | |
| 613 | 추가: let mut worker = factory.state.borrow_mut(); | |
| 614 | 추가: worker.frame(Event::Accepted { encryption: true }); | |
| 615 | 추가: worker.frame(Event::ResourceRequired(ResourceChallenge { | |
| 616 | 추가: id: 17, | |
| 617 | 추가: action: ActionKind::List, | |
| 618 | 추가: scope: ResourceScope { | |
| 619 | 추가: ratio: true, | |
| 620 | 추가: ..Default::default() | |
| 621 | 추가: }, | |
| 622 | 추가: usage: ResourceUsage::default(), | |
| 623 | 추가: soft_limits: Limits::default(), | |
| 624 | 추가: ceiling: Limits::default(), | |
| 625 | 추가: })); | |
| 626 | 추가: } | |
| 627 | 추가: let ctx = egui::Context::default(); | |
| 628 | 추가: ctx.set_embed_viewports(false); | |
| 629 | 추가: install_work_child_renderer(); | |
| 630 | 추가: for _ in 0..12 { | |
| 631 | 추가: policy_render(&ctx, &mut app, vec![]); | |
| 632 | 추가: } | |
| 633 | 추가: assert!(app.model.resource.is_some()); | |
| 634 | 추가: WORK_CHILD.with(|child| child.borrow_mut().rendered = 0); | |
| 635 | 추가: for _ in 0..3 { | |
| 636 | 추가: policy_render(&ctx, &mut app, vec![]); | |
| 637 | 추가: } | |
| 638 | 추가: assert_eq!(work_rendered(), 0); | |
| 639 | 추가: } | |
| 640 | 추가: | |
| 641 | 추가: #[test] | |
| 642 | 추가: fn expanded_retry_action_fits_native_work_window_and_starts_a_new_job() { | |
| 643 | 추가: let factory = FakeFactory::manual(); | |
| 644 | 추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), None, false); | |
| 645 | 추가: app.open_path(std::env::current_dir().unwrap().join("large.zip")); | |
| 646 | 추가: let old_job = app.model.job_id().unwrap(); | |
| 647 | 추가: { | |
| 648 | 추가: let mut worker = factory.state.borrow_mut(); | |
| 649 | 추가: worker.frame(Event::Accepted { encryption: true }); | |
| 650 | 추가: worker.frame(Event::Terminal(Terminal { | |
| 651 | 추가: outcome: Outcome::Failed, | |
| 652 | 추가: error: Some(ErrorCode::Limit), | |
| 653 | 추가: publication: Publication::None, | |
| 654 | 추가: created_count: 0, | |
| 655 | 추가: retained_partial_count: 0, | |
| 656 | 추가: durability: Durability::NotApplicable, | |
| 657 | 추가: cleanup: Cleanup::Complete, | |
| 658 | 추가: })); | |
| 659 | 추가: worker.queue.extend([ | |
| 660 | 추가: HostEvent::StdoutEof, | |
| 661 | 추가: HostEvent::StderrEof, | |
| 662 | 추가: HostEvent::Exited { success: true }, | |
| 663 | 추가: ]); | |
| 664 | 추가: } | |
| 665 | 추가: let ctx = egui::Context::default(); | |
| 666 | 추가: ctx.set_embed_viewports(false); | |
| 667 | 추가: install_work_child_renderer(); | |
| 668 | 추가: for _ in 0..12 { | |
| 669 | 추가: policy_render(&ctx, &mut app, vec![]); | |
| 670 | 추가: } | |
| 671 | 추가: assert!(app.model.can_retry_expanded()); | |
| 672 | 추가: let point = work_child_label("한도를 늘려 다시 시도").unwrap(); | |
| 673 | 추가: let width = WORK_CHILD.with(|child| { | |
| 674 | 추가: child | |
| 675 | 추가: .borrow() | |
| 676 | 추가: .builders | |
| 677 | 추가: .last() | |
| 678 | 추가: .unwrap() | |
| 679 | 추가: .1 | |
| 680 | 추가: .inner_size | |
| 681 | 추가: .unwrap() | |
| 682 | 추가: .x | |
| 683 | 추가: }); | |
| 684 | 추가: let text_width = ctx.fonts_mut(|fonts| { | |
| 685 | 추가: fonts | |
| 686 | 추가: .layout_no_wrap( | |
| 687 | 추가: "한도를 늘려 다시 시도".into(), | |
| 688 | 추가: egui::FontId::proportional(16.0), | |
| 689 | 추가: egui::Color32::BLACK, | |
| 690 | 추가: ) | |
| 691 | 추가: .size() | |
| 692 | 추가: .x | |
| 693 | 추가: }); | |
| 694 | 추가: assert!( | |
| 695 | 추가: point.x + text_width / 2.0 <= width - 16.0, | |
| 696 | 추가: "버튼 글자가 창을 벗어남: {point:?} / {text_width} / {width}" | |
| 697 | 추가: ); | |
| 698 | 추가: work_child_click(&ctx, &mut app, point); | |
| 699 | 추가: assert!(app.model.busy()); | |
| 700 | 추가: assert_ne!(app.model.job_id(), Some(old_job)); | |
| 701 | 추가: assert!(factory.state.borrow().expanded); | |
| 702 | 추가: } |