기본 앱 복원 브랜치에 최신 main을 병합한다
- 작성자
- 코노모리 카논
- 작성 시각
- 커밋
b0d2272e09521abb511bf06bc68f10913a9c7d9e
변경된 파일 16개
+1,134-37| @@ -100,6 +100,17 @@ python3 tests/ci/run_rust.py local | ||
| 100 | 100 | 화면에 새 창, 버튼, 메시지, 상태 또는 오류를 추가하거나 바꾸면 같은 PR에서 상황, 시험과 이 가이드를 갱신한다. 화면 변화가 없으면 PR 본문에 "UI 변경 없음"이라고 적는다. 사용자가 직접 올린 UI 변경에서 빠진 상황은 병합 뒤 프론트엔드 담당이 보완한다. |
| 101 | 101 | |
| 102 | 102 | |
| 103 | 추가: ## 파일 충돌 선택과 결과 | |
| 104 | 추가: | |
| 105 | 추가: - gzip-conflict-choice: 단일 GZ 파일의 충돌 선택 창. 저장 창에서 고른 이름과 세 선택을 확인한다. | |
| 106 | 추가: - conflict-choice: 파일 경로와 기존 크기, 새 크기 및 덮어쓰기, 건너뛰기, 이름 바꿔 저장을 확인합니다. Tab으로 이동하고 Space로 선택할 수 있으며 Escape 또는 작업 취소는 전체 작업을 취소합니다. | |
| 107 | 추가: - conflict-apply: "나머지 파일에도 같게 적용"이 켜진 상태입니다. 현재 작업의 남은 일반 파일 충돌에만 적용하며 이름 바꿔 저장은 같은 폴더에 번호를 붙입니다. | |
| 108 | 추가: - extract-skipped: 모든 파일을 건너뛴 정상 완료입니다. 생성된 파일이 없으며 저장 실패 경고가 없어야 합니다. | |
| 109 | 추가: - extract-renamed: 실제 저장된 새 이름을 표시합니다. 이름 변경 결과만으로 저장 성공을 판정하지 않고 별도의 생성 보고와 완료 집계가 일치해야 합니다. | |
| 110 | 추가: - extract-rename-failed: 새 이름을 정한 뒤 실제 생성 보고 없이 I/O 오류가 난 결과입니다. 실패 원인과 "아무 파일도 풀지 않았습니다"를 표시하고 "이름 바꿔 저장" 완료 안내는 표시하지 않아야 합니다. 일부 파일이 저장된 뒤 실패한 경우에도 생성 보고가 있는 이름만 저장 완료로 표시합니다. | |
| 111 | 추가: | |
| 112 | 추가: 실제 추출은 revision 3의 StartInteractive를 보내며 ZIP, 7z, TAR 계열과 단일 GZ의 파일 충돌에 같은 선택 창을 사용합니다. 목록 읽기와 ZIP 만들기는 기존 Start를 유지합니다. 위 명령은 실제 파일을 쓰지 않는 개발용 화면 미리보기입니다. 파일 기반 버튼 연동은 tests/rust-app-real-worker/conflict_flows.rs에서 확인하며, 운영체제별 실제 창 확인은 별도입니다. | |
| 113 | 추가: | |
| 103 | 114 | TAR.BZ2와 TAR.XZ의 자동 해제 폴더 이름은 미리보기에 표시되지 않는다. tests/rust-app-ui/presentation.rs의 이름 시험과 tests/rust-app-real-worker/compressed_tar_flows.rs의 실제 작업자 시험에서 복합 확장자 제거와 해제 결과를 확인한다. |
| 104 | 115 | |
| 105 | 116 | ## 설치 프로그램의 제거 안내 |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | use crate::archive_ui::*; |
| 2 | 2 | use std::{ |
| 3 | 삭제: collections::BTreeSet, | |
| 3 | 추가: collections::{BTreeMap, BTreeSet}, | |
| 4 | 4 | fs, io, |
| 5 | 5 | path::{Path, PathBuf}, |
| 6 | 6 | }; |
| @@ -133,6 +133,31 @@ pub fn target_files( | ||
| 133 | 133 | Some(names) |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 추가: pub fn resolved_targets( | |
| 137 | 추가: targets: Option<&BTreeSet<String>>, | |
| 138 | 추가: entries: &[Entry], | |
| 139 | 추가: gzip: Option<&str>, | |
| 140 | 추가: resolutions: &[Resolution], | |
| 141 | 추가: ) -> Option<BTreeSet<String>> { | |
| 142 | 추가: let mut names = targets?.clone(); | |
| 143 | 추가: let entries: BTreeMap<_, _> = entries.iter().map(|entry| (entry.id, entry)).collect(); | |
| 144 | 추가: for resolution in resolutions { | |
| 145 | 추가: let entry = entries.get(&resolution.entry_id)?; | |
| 146 | 추가: let original = gzip.unwrap_or(&entry.name).replace('\\', "/"); | |
| 147 | 추가: if !names.remove(&original) { | |
| 148 | 추가: return None; | |
| 149 | 추가: } | |
| 150 | 추가: } | |
| 151 | 추가: for resolution in resolutions { | |
| 152 | 추가: if resolution.choice != ConflictChoice::Skip | |
| 153 | 추가: && !names.insert(resolution.relative_name.replace('\\', "/")) | |
| 154 | 추가: { | |
| 155 | 추가: return None; | |
| 156 | 추가: } | |
| 157 | 추가: } | |
| 158 | 추가: Some(names) | |
| 159 | 추가: } | |
| 160 | 추가: | |
| 136 | 161 | pub fn target_directories(entries: &[Entry], selection: &Selection) -> BTreeSet<String> { |
| 137 | 162 | let mut directories = BTreeSet::new(); |
| 138 | 163 | for entry in entries.iter().filter(|entry| { |
| @@ -355,6 +380,8 @@ pub fn activity_text(model: &Model, creating: bool) -> &'static str { | ||
| 355 | 380 | "마무리하는 중" |
| 356 | 381 | } else if model.cancellation_requested() || model.cancel.is_some() { |
| 357 | 382 | "취소하는 중..." |
| 383 | 추가: } else if model.conflict.is_some() { | |
| 384 | 추가: "파일 충돌 선택 대기 중" | |
| 358 | 385 | } else if model.challenge.is_some() { |
| 359 | 386 | "암호를 입력하세요" |
| 360 | 387 | } else { |
| @@ -114,6 +114,22 @@ convert_enum!( | ||
| 114 | 114 | TooLate, |
| 115 | 115 | Finished |
| 116 | 116 | ); |
| 117 | 추가: convert_enum!( | |
| 118 | 추가: conflict_to_wire, | |
| 119 | 추가: ui::ConflictChoice, | |
| 120 | 추가: wire::ConflictChoice, | |
| 121 | 추가: Overwrite, | |
| 122 | 추가: Skip, | |
| 123 | 추가: Rename | |
| 124 | 추가: ); | |
| 125 | 추가: convert_enum!( | |
| 126 | 추가: conflict_to_ui, | |
| 127 | 추가: wire::ConflictChoice, | |
| 128 | 추가: ui::ConflictChoice, | |
| 129 | 추가: Overwrite, | |
| 130 | 추가: Skip, | |
| 131 | 추가: Rename | |
| 132 | 추가: ); | |
| 117 | 133 | fn list_to_wire(id: ui::ListId) -> wire::ListId { |
| 118 | 134 | wire::ListId { |
| 119 | 135 | catalog_version: id.catalog_version, |
| @@ -252,6 +268,32 @@ fn event_to_ui( | ||
| 252 | 268 | attempt, |
| 253 | 269 | encrypt: purpose == wire::PasswordPurpose::Encrypt, |
| 254 | 270 | }, |
| 271 | 추가: wire::Message::ConflictRequired { | |
| 272 | 추가: challenge_id, | |
| 273 | 추가: entry_id, | |
| 274 | 추가: relative_name, | |
| 275 | 추가: incoming_size, | |
| 276 | 추가: existing_size, | |
| 277 | 추가: } if expected == Some(wire::ActionKind::Extract) => { | |
| 278 | 추가: ui::Event::ConflictRequired(ui::Conflict { | |
| 279 | 추가: challenge_id, | |
| 280 | 추가: entry_id, | |
| 281 | 추가: relative_name, | |
| 282 | 추가: incoming_size, | |
| 283 | 추가: existing_size, | |
| 284 | 추가: }) | |
| 285 | 추가: } | |
| 286 | 추가: wire::Message::ConflictResolved { | |
| 287 | 추가: entry_id, | |
| 288 | 추가: relative_name, | |
| 289 | 추가: choice, | |
| 290 | 추가: } if expected == Some(wire::ActionKind::Extract) => { | |
| 291 | 추가: ui::Event::ConflictResolved(ui::Resolution { | |
| 292 | 추가: entry_id, | |
| 293 | 추가: relative_name, | |
| 294 | 추가: choice: conflict_to_ui(choice), | |
| 295 | 추가: }) | |
| 296 | 추가: } | |
| 255 | 297 | wire::Message::Progress { |
| 256 | 298 | stage, |
| 257 | 299 | processed_bytes, |
| @@ -458,8 +500,21 @@ impl ui::Connection for ProcessConnection { | ||
| 458 | 500 | self.stop.store(true, Ordering::Release); |
| 459 | 501 | "작업자 요청 상태 오류" |
| 460 | 502 | })? = Some(start.action.kind()); |
| 461 | 삭제: wire::Message::Start(start) | |
| 503 | 추가: if start.action.kind() == wire::ActionKind::Extract { | |
| 504 | 추가: wire::Message::StartInteractive(start) | |
| 505 | 추가: } else { | |
| 506 | 추가: wire::Message::Start(start) | |
| 507 | 추가: } | |
| 462 | 508 | } |
| 509 | 추가: ui::Command::ConflictReply { | |
| 510 | 추가: challenge_id, | |
| 511 | 추가: choice, | |
| 512 | 추가: apply_to_remaining, | |
| 513 | 추가: } => wire::Message::ConflictReply { | |
| 514 | 추가: challenge_id, | |
| 515 | 추가: choice: conflict_to_wire(choice), | |
| 516 | 추가: apply_to_remaining, | |
| 517 | 추가: }, | |
| 463 | 518 | ui::Command::Cancel => wire::Message::Cancel, |
| 464 | 519 | ui::Command::Password { |
| 465 | 520 | challenge_id, |
| @@ -680,3 +735,7 @@ fn supervise( | ||
| 680 | 735 | ); |
| 681 | 736 | } |
| 682 | 737 | } |
| 738 | 추가: | |
| 739 | 추가: #[cfg(test)] | |
| 740 | 추가: #[path = "../../../tests/rust-app-ui/conflict_codec.rs"] | |
| 741 | 추가: mod conflict_codec_tests; |
| @@ -202,6 +202,8 @@ pub struct ArchiveApp { | ||
| 202 | 202 | password_confirm: String, |
| 203 | 203 | password_visible: bool, |
| 204 | 204 | password_challenge: Option<u64>, |
| 205 | 추가: conflict_challenge: Option<(u64, u64)>, | |
| 206 | 추가: conflict_apply: bool, | |
| 205 | 207 | aes256: bool, |
| 206 | 208 | create: bool, |
| 207 | 209 | selected_only: bool, |
| @@ -263,6 +265,8 @@ impl ArchiveApp { | ||
| 263 | 265 | password_confirm: String::new(), |
| 264 | 266 | password_visible: false, |
| 265 | 267 | password_challenge: None, |
| 268 | 추가: conflict_challenge: None, | |
| 269 | 추가: conflict_apply: false, | |
| 266 | 270 | aes256: false, |
| 267 | 271 | create: false, |
| 268 | 272 | selected_only: false, |
| @@ -1012,6 +1016,9 @@ impl ArchiveApp { | ||
| 1012 | 1016 | if self.model.challenge.is_some() { |
| 1013 | 1017 | self.password_dialog(&ctx, new_challenge); |
| 1014 | 1018 | } |
| 1019 | 추가: if self.model.conflict.is_some() && self.model.close == Close::Open { | |
| 1020 | 추가: self.conflict_dialog(&ctx); | |
| 1021 | 추가: } | |
| 1015 | 1022 | self.close_dialog(&ctx); |
| 1016 | 1023 | self.picker_notice(&ctx); |
| 1017 | 1024 | if self.custom_frame { |
| @@ -1593,6 +1600,7 @@ impl ArchiveApp { | ||
| 1593 | 1600 | (self.create && !self.model.busy()) |
| 1594 | 1601 | || self.picker.is_some() |
| 1595 | 1602 | || self.model.challenge.is_some() |
| 1603 | 추가: || self.model.conflict.is_some() | |
| 1596 | 1604 | || self.model.close != Close::Open |
| 1597 | 1605 | } |
| 1598 | 1606 | |
| @@ -1776,13 +1784,39 @@ impl ArchiveApp { | ||
| 1776 | 1784 | let t = self.model.terminal.clone(); |
| 1777 | 1785 | let listing = matches!(self.last_request, Some(Start::List { .. })); |
| 1778 | 1786 | let creating = matches!(self.last_request, Some(Start::CreateZip { .. })); |
| 1787 | 추가: let resolved_targets = present::resolved_targets( | |
| 1788 | 추가: self.targets.as_ref(), | |
| 1789 | 추가: &self.model.entries, | |
| 1790 | 추가: matches!( | |
| 1791 | 추가: self.last_request, | |
| 1792 | 추가: Some(Start::Extract { | |
| 1793 | 추가: gzip_output_name: Some(_), | |
| 1794 | 추가: .. | |
| 1795 | 추가: }) | |
| 1796 | 추가: ) | |
| 1797 | 추가: .then_some(self.gzip_name.as_str()), | |
| 1798 | 추가: &self.model.resolutions, | |
| 1799 | 추가: ); | |
| 1800 | 추가: let skipped = self | |
| 1801 | 추가: .model | |
| 1802 | 추가: .resolutions | |
| 1803 | 추가: .iter() | |
| 1804 | 추가: .filter(|r| r.choice == ConflictChoice::Skip) | |
| 1805 | 추가: .count(); | |
| 1806 | 추가: let created_names = self | |
| 1807 | 추가: .model | |
| 1808 | 추가: .outputs | |
| 1809 | 추가: .iter() | |
| 1810 | 추가: .filter(|(_, disposition)| *disposition == Disposition::Created) | |
| 1811 | 추가: .map(|(name, _)| name.replace('\\', "/")) | |
| 1812 | 추가: .collect::<BTreeSet<_>>(); | |
| 1779 | 1813 | let warnings = if listing { |
| 1780 | 1814 | Vec::new() |
| 1781 | 1815 | } else { |
| 1782 | 1816 | present::publication_warnings( |
| 1783 | 1817 | t.as_ref(), |
| 1784 | 1818 | self.model.confirmed, |
| 1785 | 삭제: self.targets.as_ref(), | |
| 1819 | 추가: resolved_targets.as_ref(), | |
| 1786 | 1820 | &self.directories, |
| 1787 | 1821 | &self.model.outputs, |
| 1788 | 1822 | ) |
| @@ -1803,6 +1837,8 @@ impl ArchiveApp { | ||
| 1803 | 1837 | let title = if success { |
| 1804 | 1838 | if creating { |
| 1805 | 1839 | "ZIP 파일을 만들었습니다" |
| 1840 | 추가: } else if skipped > 0 && t.as_ref().is_some_and(|t| t.created_count == 0) { | |
| 1841 | 추가: "모든 파일을 건너뛰었습니다" | |
| 1806 | 1842 | } else { |
| 1807 | 1843 | "압축을 풀었습니다" |
| 1808 | 1844 | } |
| @@ -1846,7 +1882,7 @@ impl ArchiveApp { | ||
| 1846 | 1882 | .id_salt("result-message") |
| 1847 | 1883 | .max_height(max_height) |
| 1848 | 1884 | .show(ui, |ui| { |
| 1849 | 삭제: if success { | |
| 1885 | 추가: if success && t.as_ref().is_some_and(|t| t.created_count > 0) { | |
| 1850 | 1886 | let path = match self.last_request.as_ref() { |
| 1851 | 1887 | Some(Start::CreateZip { output_file, .. }) => { |
| 1852 | 1888 | output_file.display().to_string() |
| @@ -1866,6 +1902,19 @@ impl ArchiveApp { | ||
| 1866 | 1902 | creating, |
| 1867 | 1903 | )); |
| 1868 | 1904 | } |
| 1905 | 추가: if skipped > 0 { | |
| 1906 | 추가: ui.label(format!("건너뛴 파일 {skipped}개")); | |
| 1907 | 추가: } | |
| 1908 | 추가: for resolution in self.model.resolutions.iter().filter(|r| { | |
| 1909 | 추가: r.choice == ConflictChoice::Rename | |
| 1910 | 추가: && created_names.contains(&r.relative_name.replace('\\', "/")) | |
| 1911 | 추가: }) { | |
| 1912 | 추가: theme::bounded_text( | |
| 1913 | 추가: ui, | |
| 1914 | 추가: &format!("이름 바꿔 저장: {}", resolution.relative_name), | |
| 1915 | 추가: ui.available_width(), | |
| 1916 | 추가: ); | |
| 1917 | 추가: } | |
| 1869 | 1918 | for warning in warnings |
| 1870 | 1919 | .iter() |
| 1871 | 1920 | .copied() |
| @@ -2383,6 +2432,57 @@ impl ArchiveApp { | ||
| 2383 | 2432 | cancel |
| 2384 | 2433 | } |
| 2385 | 2434 | |
| 2435 | 추가: fn conflict_dialog(&mut self, ctx: &egui::Context) { | |
| 2436 | 추가: let conflict = self.model.conflict.clone().unwrap(); | |
| 2437 | 추가: let question = (self.model.job_id().unwrap_or(0), conflict.challenge_id); | |
| 2438 | 추가: if self.conflict_challenge != Some(question) { | |
| 2439 | 추가: self.conflict_challenge = Some(question); | |
| 2440 | 추가: self.conflict_apply = false; | |
| 2441 | 추가: } | |
| 2442 | 추가: let mut choice = None; | |
| 2443 | 추가: let mut cancel = false; | |
| 2444 | 추가: let modal = egui::Modal::new(egui::Id::unique("archive-conflict")).show(ctx, |ui| { | |
| 2445 | 추가: ui.set_width((ctx.content_rect().width() - 64.0).min(460.0)); | |
| 2446 | 추가: ui.heading("같은 이름의 파일이 있습니다"); | |
| 2447 | 추가: theme::bounded_text(ui, &conflict.relative_name, ui.available_width()); | |
| 2448 | 추가: ui.add_space(theme::SPACE); | |
| 2449 | 추가: egui::Grid::new("conflict-sizes") | |
| 2450 | 추가: .spacing([24.0, 8.0]) | |
| 2451 | 추가: .show(ui, |ui| { | |
| 2452 | 추가: ui.label("기존 파일"); | |
| 2453 | 추가: ui.label(present::bytes_text(conflict.existing_size)); | |
| 2454 | 추가: ui.end_row(); | |
| 2455 | 추가: ui.label("압축파일 안의 파일"); | |
| 2456 | 추가: ui.label(present::bytes_text(conflict.incoming_size)); | |
| 2457 | 추가: ui.end_row(); | |
| 2458 | 추가: }); | |
| 2459 | 추가: ui.add_space(theme::SPACE); | |
| 2460 | 추가: ui.checkbox(&mut self.conflict_apply, "나머지 파일에도 같게 적용"); | |
| 2461 | 추가: ui.add_space(theme::SPACE); | |
| 2462 | 추가: ui.horizontal_wrapped(|ui| { | |
| 2463 | 추가: for (label, value) in [ | |
| 2464 | 추가: ("덮어쓰기", ConflictChoice::Overwrite), | |
| 2465 | 추가: ("건너뛰기", ConflictChoice::Skip), | |
| 2466 | 추가: ("이름 바꿔 저장", ConflictChoice::Rename), | |
| 2467 | 추가: ] { | |
| 2468 | 추가: if theme::action(ui, label, false, self.model.error.is_none()).clicked() { | |
| 2469 | 추가: choice = Some(value); | |
| 2470 | 추가: } | |
| 2471 | 추가: } | |
| 2472 | 추가: }); | |
| 2473 | 추가: ui.label("이름 바꿔 저장하면 같은 폴더에 번호를 붙입니다."); | |
| 2474 | 추가: if let Some(error) = &self.model.error { | |
| 2475 | 추가: Self::error_notice(ui, present::client_error_text(error)); | |
| 2476 | 추가: } | |
| 2477 | 추가: cancel = theme::action(ui, "작업 취소", false, true).clicked(); | |
| 2478 | 추가: }); | |
| 2479 | 추가: if modal.should_close() || cancel { | |
| 2480 | 추가: self.model.cancel(); | |
| 2481 | 추가: } else if let Some(choice) = choice { | |
| 2482 | 추가: self.model.resolve_conflict(choice, self.conflict_apply); | |
| 2483 | 추가: } | |
| 2484 | 추가: } | |
| 2485 | 추가: | |
| 2386 | 2486 | fn password_dialog(&mut self, ctx: &egui::Context, new_challenge: bool) { |
| 2387 | 2487 | let (_, attempt, encrypt) = self.model.challenge.unwrap(); |
| 2388 | 2488 | let mut submit = false; |
| @@ -70,9 +70,37 @@ impl Drop for Secret { | ||
| 70 | 70 | self.0.fill(0); |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 74 | 추가: pub enum ConflictChoice { | |
| 75 | 추가: Overwrite, | |
| 76 | 추가: Skip, | |
| 77 | 추가: Rename, | |
| 78 | 추가: } | |
| 79 | 추가: #[derive(Clone, Debug, Eq, PartialEq)] | |
| 80 | 추가: pub struct Conflict { | |
| 81 | 추가: pub challenge_id: u64, | |
| 82 | 추가: pub entry_id: u32, | |
| 83 | 추가: pub relative_name: String, | |
| 84 | 추가: pub incoming_size: u64, | |
| 85 | 추가: pub existing_size: u64, | |
| 86 | 추가: } | |
| 87 | 추가: #[derive(Clone, Debug, Eq, PartialEq)] | |
| 88 | 추가: pub struct Resolution { | |
| 89 | 추가: pub entry_id: u32, | |
| 90 | 추가: pub relative_name: String, | |
| 91 | 추가: pub choice: ConflictChoice, | |
| 92 | 추가: } | |
| 73 | 93 | pub enum Command { |
| 74 | 94 | Start(Start), |
| 75 | 삭제: Password { challenge_id: u64, secret: Secret }, | |
| 95 | 추가: Password { | |
| 96 | 추가: challenge_id: u64, | |
| 97 | 추가: secret: Secret, | |
| 98 | 추가: }, | |
| 99 | 추가: ConflictReply { | |
| 100 | 추가: challenge_id: u64, | |
| 101 | 추가: choice: ConflictChoice, | |
| 102 | 추가: apply_to_remaining: bool, | |
| 103 | 추가: }, | |
| 76 | 104 | Cancel, |
| 77 | 105 | } |
| 78 | 106 | pub struct Request { |
| @@ -186,6 +214,8 @@ pub enum Event { | ||
| 186 | 214 | attempt: u32, |
| 187 | 215 | encrypt: bool, |
| 188 | 216 | }, |
| 217 | 추가: ConflictRequired(Conflict), | |
| 218 | 추가: ConflictResolved(Resolution), | |
| 189 | 219 | Progress { |
| 190 | 220 | stage: Stage, |
| 191 | 221 | processed: u64, |
| @@ -247,6 +277,9 @@ struct Running { | ||
| 247 | 277 | stderr_eof: bool, |
| 248 | 278 | exit: Option<bool>, |
| 249 | 279 | cancel_sequence: Option<u64>, |
| 280 | 추가: conflict_ids: BTreeSet<u64>, | |
| 281 | 추가: resolved_ids: BTreeSet<u32>, | |
| 282 | 추가: file_ids: BTreeSet<u32>, | |
| 250 | 283 | } |
| 251 | 284 | #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] |
| 252 | 285 | pub enum Close { |
| @@ -267,6 +300,8 @@ pub struct Model { | ||
| 267 | 300 | pub selected: BTreeSet<u32>, |
| 268 | 301 | pub terminal: Option<Terminal>, |
| 269 | 302 | pub challenge: Option<(u64, u32, bool)>, |
| 303 | 추가: pub conflict: Option<Conflict>, | |
| 304 | 추가: pub resolutions: Vec<Resolution>, | |
| 270 | 305 | pub progress: Option<(Stage, u64, Option<u64>, u64)>, |
| 271 | 306 | pub outputs: Vec<(String, Disposition)>, |
| 272 | 307 | pub cancel: Option<CancelStatus>, |
| @@ -375,6 +410,8 @@ impl Model { | ||
| 375 | 410 | self.next_id = id; |
| 376 | 411 | self.terminal = None; |
| 377 | 412 | self.challenge = None; |
| 413 | 추가: self.conflict = None; | |
| 414 | 추가: self.resolutions.clear(); | |
| 378 | 415 | self.progress = None; |
| 379 | 416 | self.outputs.clear(); |
| 380 | 417 | self.cancel = None; |
| @@ -396,6 +433,14 @@ impl Model { | ||
| 396 | 433 | stderr_eof: false, |
| 397 | 434 | exit: None, |
| 398 | 435 | cancel_sequence: None, |
| 436 | 추가: conflict_ids: BTreeSet::new(), | |
| 437 | 추가: resolved_ids: BTreeSet::new(), | |
| 438 | 추가: file_ids: self | |
| 439 | 추가: .entries | |
| 440 | 추가: .iter() | |
| 441 | 추가: .filter(|e| e.kind == Kind::File) | |
| 442 | 추가: .map(|e| e.id) | |
| 443 | 추가: .collect(), | |
| 399 | 444 | }); |
| 400 | 445 | started |
| 401 | 446 | } |
| @@ -443,6 +488,29 @@ impl Model { | ||
| 443 | 488 | .is_some() |
| 444 | 489 | { |
| 445 | 490 | self.challenge = None; |
| 491 | 추가: self.conflict = None; | |
| 492 | 추가: self.input_error = None; | |
| 493 | 추가: true | |
| 494 | 추가: } else { | |
| 495 | 추가: false | |
| 496 | 추가: } | |
| 497 | 추가: } | |
| 498 | 추가: pub fn resolve_conflict(&mut self, choice: ConflictChoice, apply_to_remaining: bool) -> bool { | |
| 499 | 추가: let Some(conflict) = &self.conflict else { | |
| 500 | 추가: return false; | |
| 501 | 추가: }; | |
| 502 | 추가: if self.cancellation_requested() || self.error.is_some() || self.close != Close::Open { | |
| 503 | 추가: return false; | |
| 504 | 추가: } | |
| 505 | 추가: if self | |
| 506 | 추가: .send(Command::ConflictReply { | |
| 507 | 추가: challenge_id: conflict.challenge_id, | |
| 508 | 추가: choice, | |
| 509 | 추가: apply_to_remaining, | |
| 510 | 추가: }) | |
| 511 | 추가: .is_some() | |
| 512 | 추가: { | |
| 513 | 추가: self.conflict = None; | |
| 446 | 514 | self.input_error = None; |
| 447 | 515 | true |
| 448 | 516 | } else { |
| @@ -483,6 +551,7 @@ impl Model { | ||
| 483 | 551 | if let Some(seq) = self.send(Command::Cancel) { |
| 484 | 552 | self.running.as_mut().unwrap().cancel_sequence = Some(seq); |
| 485 | 553 | self.challenge = None; |
| 554 | 추가: self.conflict = None; | |
| 486 | 555 | self.input_error = None; |
| 487 | 556 | } |
| 488 | 557 | } |
| @@ -565,6 +634,7 @@ impl Model { | ||
| 565 | 634 | self.selected.clear(); |
| 566 | 635 | } |
| 567 | 636 | self.challenge = None; |
| 637 | 추가: self.conflict = None; | |
| 568 | 638 | self.input_error = None; |
| 569 | 639 | if matches!(self.close, Close::Waiting | Close::Confirm) { |
| 570 | 640 | self.close = Close::Review; |
| @@ -636,12 +706,46 @@ impl Model { | ||
| 636 | 706 | attempt, |
| 637 | 707 | encrypt, |
| 638 | 708 | } => { |
| 639 | 삭제: if self.challenge.is_some() || challenge_id == 0 { | |
| 709 | 추가: if self.challenge.is_some() || self.conflict.is_some() || challenge_id == 0 | |
| 710 | 추가: { | |
| 640 | 711 | self.error = Some("암호 요청이 유효하지 않습니다".into()); |
| 641 | 712 | } else { |
| 642 | 713 | self.challenge = Some((challenge_id, attempt, encrypt)); |
| 643 | 714 | } |
| 644 | 715 | } |
| 716 | 추가: Event::ConflictRequired(conflict) => { | |
| 717 | 추가: let valid_entry = self | |
| 718 | 추가: .entries | |
| 719 | 추가: .iter() | |
| 720 | 추가: .any(|entry| entry.id == conflict.entry_id && entry.kind == Kind::File); | |
| 721 | 추가: if !matches!(run.start, Start::Extract { .. }) | |
| 722 | 추가: || !valid_entry | |
| 723 | 추가: || conflict.challenge_id == 0 | |
| 724 | 추가: || self.challenge.is_some() | |
| 725 | 추가: || self.conflict.is_some() | |
| 726 | 추가: || run.conflict_ids.len() >= 100_000 | |
| 727 | 추가: || !valid_relative(&conflict.relative_name) | |
| 728 | 추가: || conflict.relative_name.len() > 4096 | |
| 729 | 추가: || !run.conflict_ids.insert(conflict.challenge_id) | |
| 730 | 추가: { | |
| 731 | 추가: self.error = Some("파일 충돌 요청이 유효하지 않습니다".into()); | |
| 732 | 추가: } else if run.cancel_sequence.is_none() { | |
| 733 | 추가: self.conflict = Some(conflict); | |
| 734 | 추가: } | |
| 735 | 추가: } | |
| 736 | 추가: Event::ConflictResolved(resolution) => { | |
| 737 | 추가: if !matches!(run.start, Start::Extract { .. }) | |
| 738 | 추가: || !run.file_ids.contains(&resolution.entry_id) | |
| 739 | 추가: || self.resolutions.len() >= 100_000 | |
| 740 | 추가: || !valid_relative(&resolution.relative_name) | |
| 741 | 추가: || resolution.relative_name.len() > 4096 | |
| 742 | 추가: || !run.resolved_ids.insert(resolution.entry_id) | |
| 743 | 추가: { | |
| 744 | 추가: self.error = Some("파일 충돌 결과가 유효하지 않습니다".into()); | |
| 745 | 추가: } else { | |
| 746 | 추가: self.resolutions.push(resolution); | |
| 747 | 추가: } | |
| 748 | 추가: } | |
| 645 | 749 | Event::Progress { |
| 646 | 750 | stage, |
| 647 | 751 | processed, |
| @@ -671,6 +775,7 @@ impl Model { | ||
| 671 | 775 | } |
| 672 | 776 | Event::Terminal(t) => { |
| 673 | 777 | self.challenge = None; |
| 778 | 추가: self.conflict = None; | |
| 674 | 779 | self.terminal = Some(t); |
| 675 | 780 | } |
| 676 | 781 | } |
| @@ -685,6 +790,9 @@ impl Model { | ||
| 685 | 790 | if self.terminal.is_some() { |
| 686 | 791 | return "작업 결과 수신 / 프로세스 종료 확인 중".into(); |
| 687 | 792 | } |
| 793 | 추가: if self.conflict.is_some() { | |
| 794 | 추가: return "같은 이름의 파일을 처리할 방법을 선택하세요".into(); | |
| 795 | 추가: } | |
| 688 | 796 | if self.challenge.is_some() { |
| 689 | 797 | return "암호를 입력하세요".into(); |
| 690 | 798 | } |
| @@ -0,0 +1,231 @@ | ||
| 1 | 추가: fn conflict_fixture(scratch: &Scratch) -> (PathBuf, PathBuf) { | |
| 2 | 추가: use worker_protocol::{archive, protocol}; | |
| 3 | 추가: let members = ["기록.txt", "사진.txt"] | |
| 4 | 추가: .into_iter() | |
| 5 | 추가: .enumerate() | |
| 6 | 추가: .map(|(id, name)| archive::Member { | |
| 7 | 추가: entry: protocol::Entry { | |
| 8 | 추가: entry_id: id as u32, | |
| 9 | 추가: name: name.into(), | |
| 10 | 추가: kind: protocol::EntryKind::File, | |
| 11 | 추가: size: 3, | |
| 12 | 추가: compressed_size: 3, | |
| 13 | 추가: encrypted: false, | |
| 14 | 추가: }, | |
| 15 | 추가: data: b"new".to_vec(), | |
| 16 | 추가: }) | |
| 17 | 추가: .collect::<Vec<_>>(); | |
| 18 | 추가: let archive = scratch.path("충돌.zip"); | |
| 19 | 추가: fs::write( | |
| 20 | 추가: &archive, | |
| 21 | 추가: archive::create_zip( | |
| 22 | 추가: &members, | |
| 23 | 추가: protocol::Method::Store, | |
| 24 | 추가: protocol::Limits::default(), | |
| 25 | 추가: &mut || Ok(()), | |
| 26 | 추가: ) | |
| 27 | 추가: .unwrap(), | |
| 28 | 추가: ) | |
| 29 | 추가: .unwrap(); | |
| 30 | 추가: let output = make_directory(&scratch.path("output")); | |
| 31 | 추가: for name in ["기록.txt", "사진.txt"] { | |
| 32 | 추가: fs::write(output.join(name), b"original").unwrap(); | |
| 33 | 추가: } | |
| 34 | 추가: (archive, output) | |
| 35 | 추가: } | |
| 36 | 추가: | |
| 37 | 추가: impl Screen { | |
| 38 | 추가: fn start_conflicting_extract(&mut self, output: &Path) { | |
| 39 | 추가: self.app.choose_destination(output.to_path_buf()); | |
| 40 | 추가: self.dialogs | |
| 41 | 추가: .0 | |
| 42 | 추가: .borrow_mut() | |
| 43 | 추가: .answers | |
| 44 | 추가: .push_back(Some(vec![output.to_path_buf()])); | |
| 45 | 추가: self.click("압축해제"); | |
| 46 | 추가: assert!(self.app.model.busy()); | |
| 47 | 추가: } | |
| 48 | 추가: | |
| 49 | 추가: fn await_conflict(&mut self) -> Conflict { | |
| 50 | 추가: let deadline = Instant::now() + Duration::from_secs(10); | |
| 51 | 추가: loop { | |
| 52 | 추가: self.render(vec![]); | |
| 53 | 추가: if let Some(conflict) = &self.app.model.conflict { | |
| 54 | 추가: return conflict.clone(); | |
| 55 | 추가: } | |
| 56 | 추가: assert!( | |
| 57 | 추가: self.app.model.busy(), | |
| 58 | 추가: "충돌 질문 전에 종료됨: {:?}", | |
| 59 | 추가: self.app.model.terminal | |
| 60 | 추가: ); | |
| 61 | 추가: assert!(Instant::now() < deadline, "충돌 질문 시간 초과"); | |
| 62 | 추가: std::thread::sleep(Duration::from_millis(2)); | |
| 63 | 추가: } | |
| 64 | 추가: } | |
| 65 | 추가: | |
| 66 | 추가: fn settle_conflict_result(&mut self) { | |
| 67 | 추가: let deadline = Instant::now() + Duration::from_secs(10); | |
| 68 | 추가: while self.app.model.busy() { | |
| 69 | 추가: self.render(vec![]); | |
| 70 | 추가: assert!(Instant::now() < deadline, "충돌 결과 시간 초과"); | |
| 71 | 추가: std::thread::sleep(Duration::from_millis(2)); | |
| 72 | 추가: } | |
| 73 | 추가: assert!(self.app.model.confirmed, "{}", self.app.model.status()); | |
| 74 | 추가: assert!(self.app.model.conflict.is_none()); | |
| 75 | 추가: } | |
| 76 | 추가: } | |
| 77 | 추가: | |
| 78 | 추가: #[test] | |
| 79 | 추가: fn real_conflicts_follow_widget_choices_and_apply_remaining() { | |
| 80 | 추가: for (label, choice) in [ | |
| 81 | 추가: ("덮어쓰기", ConflictChoice::Overwrite), | |
| 82 | 추가: ("건너뛰기", ConflictChoice::Skip), | |
| 83 | 추가: ("이름 바꿔 저장", ConflictChoice::Rename), | |
| 84 | 추가: ] { | |
| 85 | 추가: for apply in [false, true] { | |
| 86 | 추가: let scratch = Scratch::new(); | |
| 87 | 추가: let (archive, output) = conflict_fixture(&scratch); | |
| 88 | 추가: let (factory, observed) = observed_factory(); | |
| 89 | 추가: let mut screen = Screen::new(factory); | |
| 90 | 추가: screen.open(&archive); | |
| 91 | 추가: screen.start_conflicting_extract(&output); | |
| 92 | 추가: let first = screen.await_conflict(); | |
| 93 | 추가: assert_eq!(first.incoming_size, 3); | |
| 94 | 추가: assert_eq!(first.existing_size, 8); | |
| 95 | 추가: if apply { | |
| 96 | 추가: screen.click("나머지 파일에도 같게 적용"); | |
| 97 | 추가: } | |
| 98 | 추가: screen.click(label); | |
| 99 | 추가: if !apply { | |
| 100 | 추가: let second = screen.await_conflict(); | |
| 101 | 추가: assert_ne!(first.challenge_id, second.challenge_id); | |
| 102 | 추가: assert_ne!(first.entry_id, second.entry_id); | |
| 103 | 추가: screen.click(label); | |
| 104 | 추가: } | |
| 105 | 추가: screen.settle_conflict_result(); | |
| 106 | 추가: completed(&screen.app.model); | |
| 107 | 추가: assert_eq!(screen.app.model.resolutions.len(), 2); | |
| 108 | 추가: assert!( | |
| 109 | 추가: screen | |
| 110 | 추가: .app | |
| 111 | 추가: .model | |
| 112 | 추가: .resolutions | |
| 113 | 추가: .iter() | |
| 114 | 추가: .all(|r| r.choice == choice) | |
| 115 | 추가: ); | |
| 116 | 추가: let terminal = screen.app.model.terminal.as_ref().unwrap(); | |
| 117 | 추가: assert_eq!( | |
| 118 | 추가: terminal.created_count, | |
| 119 | 추가: if choice == ConflictChoice::Skip { 0 } else { 2 } | |
| 120 | 추가: ); | |
| 121 | 추가: assert_eq!( | |
| 122 | 추가: terminal.publication, | |
| 123 | 추가: if choice == ConflictChoice::Skip { | |
| 124 | 추가: Publication::None | |
| 125 | 추가: } else { | |
| 126 | 추가: Publication::Complete | |
| 127 | 추가: } | |
| 128 | 추가: ); | |
| 129 | 추가: for name in ["기록.txt", "사진.txt"] { | |
| 130 | 추가: assert_eq!( | |
| 131 | 추가: fs::read(output.join(name)).unwrap(), | |
| 132 | 추가: if choice == ConflictChoice::Overwrite { | |
| 133 | 추가: b"new".as_slice() | |
| 134 | 추가: } else { | |
| 135 | 추가: b"original".as_slice() | |
| 136 | 추가: } | |
| 137 | 추가: ); | |
| 138 | 추가: } | |
| 139 | 추가: for resolution in &screen.app.model.resolutions { | |
| 140 | 추가: if choice == ConflictChoice::Rename { | |
| 141 | 추가: assert_eq!( | |
| 142 | 추가: fs::read(output.join(&resolution.relative_name)).unwrap(), | |
| 143 | 추가: b"new" | |
| 144 | 추가: ); | |
| 145 | 추가: assert!(resolution.relative_name.contains(" (1)")); | |
| 146 | 추가: } | |
| 147 | 추가: } | |
| 148 | 추가: let shown = screen | |
| 149 | 추가: .render(vec![]) | |
| 150 | 추가: .into_iter() | |
| 151 | 추가: .map(|(t, _)| t) | |
| 152 | 추가: .collect::<Vec<_>>() | |
| 153 | 추가: .join("\n"); | |
| 154 | 추가: assert!( | |
| 155 | 추가: shown.contains(if choice == ConflictChoice::Skip { | |
| 156 | 추가: "모든 파일을 건너뛰었습니다" | |
| 157 | 추가: } else { | |
| 158 | 추가: "압축을 풀었습니다" | |
| 159 | 추가: }), | |
| 160 | 추가: "{shown}" | |
| 161 | 추가: ); | |
| 162 | 추가: assert!(!shown.contains("저장이 끝났는지"), "{shown}"); | |
| 163 | 추가: assert_reaped(&observed); | |
| 164 | 추가: } | |
| 165 | 추가: } | |
| 166 | 추가: } | |
| 167 | 추가: | |
| 168 | 추가: #[test] | |
| 169 | 추가: fn real_conflict_cancel_button_and_escape_preserve_originals() { | |
| 170 | 추가: for escape in [false, true] { | |
| 171 | 추가: let scratch = Scratch::new(); | |
| 172 | 추가: let (archive, output) = conflict_fixture(&scratch); | |
| 173 | 추가: let (factory, observed) = observed_factory(); | |
| 174 | 추가: let mut screen = Screen::new(factory); | |
| 175 | 추가: screen.open(&archive); | |
| 176 | 추가: screen.start_conflicting_extract(&output); | |
| 177 | 추가: screen.await_conflict(); | |
| 178 | 추가: if escape { | |
| 179 | 추가: screen.escape(); | |
| 180 | 추가: } else { | |
| 181 | 추가: screen.click("작업 취소"); | |
| 182 | 추가: } | |
| 183 | 추가: screen.settle_conflict_result(); | |
| 184 | 추가: assert_eq!( | |
| 185 | 추가: screen.app.model.terminal.as_ref().unwrap().outcome, | |
| 186 | 추가: Outcome::Cancelled | |
| 187 | 추가: ); | |
| 188 | 추가: assert!(screen.app.model.outputs.is_empty()); | |
| 189 | 추가: for name in ["기록.txt", "사진.txt"] { | |
| 190 | 추가: assert_eq!(fs::read(output.join(name)).unwrap(), b"original"); | |
| 191 | 추가: } | |
| 192 | 추가: assert_reaped(&observed); | |
| 193 | 추가: } | |
| 194 | 추가: } | |
| 195 | 추가: | |
| 196 | 추가: #[test] | |
| 197 | 추가: fn target_changed_during_real_question_fails_without_saved_name_notice() { | |
| 198 | 추가: let scratch = Scratch::new(); | |
| 199 | 추가: let (archive, output) = conflict_fixture(&scratch); | |
| 200 | 추가: let (factory, observed) = observed_factory(); | |
| 201 | 추가: let mut screen = Screen::new(factory); | |
| 202 | 추가: screen.open(&archive); | |
| 203 | 추가: screen.start_conflicting_extract(&output); | |
| 204 | 추가: let conflict = screen.await_conflict(); | |
| 205 | 추가: fs::write( | |
| 206 | 추가: output.join(&conflict.relative_name), | |
| 207 | 추가: b"changed after question", | |
| 208 | 추가: ) | |
| 209 | 추가: .unwrap(); | |
| 210 | 추가: screen.click("덮어쓰기"); | |
| 211 | 추가: screen.settle_conflict_result(); | |
| 212 | 추가: assert_eq!( | |
| 213 | 추가: screen.app.model.terminal.as_ref().unwrap().outcome, | |
| 214 | 추가: Outcome::Failed | |
| 215 | 추가: ); | |
| 216 | 추가: assert_eq!(screen.app.model.terminal.as_ref().unwrap().created_count, 0); | |
| 217 | 추가: assert!(screen.app.model.outputs.is_empty()); | |
| 218 | 추가: assert_eq!( | |
| 219 | 추가: fs::read(output.join(&conflict.relative_name)).unwrap(), | |
| 220 | 추가: b"changed after question" | |
| 221 | 추가: ); | |
| 222 | 추가: let shown = screen | |
| 223 | 추가: .render(vec![]) | |
| 224 | 추가: .into_iter() | |
| 225 | 추가: .map(|(t, _)| t) | |
| 226 | 추가: .collect::<Vec<_>>() | |
| 227 | 추가: .join("\n"); | |
| 228 | 추가: assert!(shown.contains("압축을 풀지 못했습니다"), "{shown}"); | |
| 229 | 추가: assert!(!shown.contains("이름 바꿔 저장:"), "{shown}"); | |
| 230 | 추가: assert_reaped(&observed); | |
| 231 | 추가: } |
| @@ -304,12 +304,17 @@ mod screen { | ||
| 304 | 304 | self.settle(); |
| 305 | 305 | assert_eq!( |
| 306 | 306 | self.app.model.terminal.as_ref().unwrap().publication, |
| 307 | 삭제: Publication::Complete | |
| 307 | 추가: if self.app.model.terminal.as_ref().unwrap().created_count == 0 { | |
| 308 | 추가: Publication::None | |
| 309 | 추가: } else { | |
| 310 | 추가: Publication::Complete | |
| 311 | 추가: } | |
| 308 | 312 | ); |
| 309 | 313 | } |
| 310 | 314 | } |
| 311 | 315 | include!("password_flows.rs"); |
| 312 | 316 | include!("selection_flows.rs"); |
| 317 | 추가: include!("conflict_flows.rs"); | |
| 313 | 318 | include!("native_dialog_flows.rs"); |
| 314 | 319 | include!("compressed_tar_flows.rs"); |
| 315 | 320 |
| @@ -5,12 +5,13 @@ fn native_fixture(scratch: &Scratch, fixture: &str, name: &str) -> PathBuf { | ||
| 5 | 5 | .join("../../tests/rust-app-real-worker/fixtures") |
| 6 | 6 | .join(fixture), |
| 7 | 7 | &target, |
| 8 | 삭제: ).unwrap(); | |
| 8 | 추가: ) | |
| 9 | 추가: .unwrap(); | |
| 9 | 10 | target |
| 10 | 11 | } |
| 11 | 12 | |
| 12 | 13 | #[test] |
| 13 | 삭제: fn raw_gzip_save_dialog_corrects_names_and_preserves_cancel_and_conflict_retry() { | |
| 14 | 추가: fn raw_gzip_save_dialog_corrects_names_and_preserves_cancel_and_conflict_choice() { | |
| 14 | 15 | use zipelo_ui_memory_app::archive_dialog::Purpose; |
| 15 | 16 | let mut names = vec![".gz", "report.GZ", "report.Gz", "report.gz"]; |
| 16 | 17 | #[cfg(unix)] |
| @@ -23,41 +24,46 @@ fn raw_gzip_save_dialog_corrects_names_and_preserves_cancel_and_conflict_retry() | ||
| 23 | 24 | let (factory, observed) = observed_factory(); |
| 24 | 25 | let mut screen = Screen::new(factory); |
| 25 | 26 | screen.open(&archive); |
| 26 | 삭제: assert_eq!(screen.app.model.list_id.as_ref().unwrap().format, Format::Gzip); | |
| 27 | 추가: assert_eq!( | |
| 28 | 추가: screen.app.model.list_id.as_ref().unwrap().format, | |
| 29 | 추가: Format::Gzip | |
| 30 | 추가: ); | |
| 27 | 31 | screen.click("압축해제"); |
| 28 | 32 | assert!(!screen.app.model.busy()); |
| 29 | 33 | assert_eq!(observed.borrow().jobs.len(), 1); |
| 30 | 34 | let request = screen.dialogs.0.borrow().requests.last().unwrap().clone(); |
| 31 | 35 | assert_eq!(request.purpose, Purpose::SaveGzip); |
| 32 | 36 | assert_eq!(request.directory, scratch.0); |
| 33 | 삭제: assert_eq!(request.file_name, if name == ".gz" || name.contains(':') { "압축 해제 파일" } else { "report" }); | |
| 37 | 추가: assert_eq!( | |
| 38 | 추가: request.file_name, | |
| 39 | 추가: if name == ".gz" || name.contains(':') { | |
| 40 | 추가: "압축 해제 파일" | |
| 41 | 추가: } else { | |
| 42 | 추가: "report" | |
| 43 | 추가: } | |
| 44 | 추가: ); | |
| 34 | 45 | let existing = output.join("기존 파일.txt"); |
| 35 | 46 | fs::write(&existing, b"preserve").unwrap(); |
| 36 | 삭제: screen.dialogs.0.borrow_mut().answers.push_back(Some(vec![existing.clone()])); | |
| 47 | 추가: screen | |
| 48 | 추가: .dialogs | |
| 49 | 추가: .0 | |
| 50 | 추가: .borrow_mut() | |
| 51 | 추가: .answers | |
| 52 | 추가: .push_back(Some(vec![existing.clone()])); | |
| 37 | 53 | screen.click("압축해제"); |
| 38 | 삭제: let deadline = Instant::now() + Duration::from_secs(10); | |
| 39 | 삭제: while screen.app.model.busy() { | |
| 40 | 삭제: screen.render(vec![]); | |
| 41 | 삭제: assert!(Instant::now() < deadline); | |
| 42 | 삭제: std::thread::sleep(Duration::from_millis(2)); | |
| 43 | 삭제: } | |
| 44 | 삭제: assert_eq!(screen.app.model.terminal.as_ref().unwrap().error, Some(ErrorCode::Conflict)); | |
| 45 | 삭제: assert_eq!(fs::read(&existing).unwrap(), b"preserve"); | |
| 46 | 삭제: screen.click("다른 이름으로 저장"); | |
| 47 | 삭제: assert!(!screen.app.model.busy()); | |
| 48 | 삭제: assert_eq!(observed.borrow().jobs.len(), 2); | |
| 49 | 삭제: assert_eq!(screen.dialogs.0.borrow().requests.last().unwrap().purpose, Purpose::RetryGzip); | |
| 50 | 삭제: let saved = output.join("사용자 이름.txt"); | |
| 51 | 삭제: screen.dialogs.0.borrow_mut().answers.push_back(Some(vec![saved.clone()])); | |
| 52 | 삭제: screen.click("다른 이름으로 저장"); | |
| 53 | 삭제: screen.settle(); | |
| 54 | 추가: let conflict = screen.await_conflict(); | |
| 55 | 추가: assert_eq!(conflict.relative_name, "기존 파일.txt"); | |
| 56 | 추가: screen.click("이름 바꿔 저장"); | |
| 57 | 추가: screen.settle_conflict_result(); | |
| 58 | 추가: completed(&screen.app.model); | |
| 59 | 추가: let saved = output.join("기존 파일 (1).txt"); | |
| 54 | 60 | assert_eq!(fs::read(saved).unwrap(), b"Zipelo real worker flow\n"); |
| 55 | 61 | assert_eq!(fs::read(existing).unwrap(), b"preserve"); |
| 56 | 62 | assert_eq!(fs::read(&archive).unwrap(), original); |
| 57 | 63 | assert!(matches!( |
| 58 | 64 | observed.borrow().starts.last(), |
| 59 | 65 | Some(Start::Extract { destination, gzip_output_name: Some(name), .. }) |
| 60 | 삭제: if destination == &output && name == "사용자 이름.txt" | |
| 66 | 추가: if destination == &output && name == "기존 파일.txt" | |
| 61 | 67 | )); |
| 62 | 68 | assert_reaped(&observed); |
| 63 | 69 | } |
| @@ -73,13 +79,24 @@ fn mixed_case_zip_names_open_and_extract_through_native_dialog_responses() { | ||
| 73 | 79 | let output = make_directory(&scratch.path("output")); |
| 74 | 80 | let (factory, observed) = observed_factory(); |
| 75 | 81 | let mut screen = Screen::new(factory); |
| 76 | 삭제: screen.dialogs.0.borrow_mut().answers.push_back(Some(vec![archive.clone()])); | |
| 82 | 추가: screen | |
| 83 | 추가: .dialogs | |
| 84 | 추가: .0 | |
| 85 | 추가: .borrow_mut() | |
| 86 | 추가: .answers | |
| 87 | 추가: .push_back(Some(vec![archive.clone()])); | |
| 77 | 88 | screen.click("열기"); |
| 78 | 89 | screen.settle(); |
| 79 | 90 | assert_eq!(screen.dialogs.0.borrow().requests[0].purpose, Purpose::Open); |
| 80 | 삭제: assert_eq!(screen.app.model.list_id.as_ref().unwrap().format, Format::Zip); | |
| 91 | 추가: assert_eq!( | |
| 92 | 추가: screen.app.model.list_id.as_ref().unwrap().format, | |
| 93 | 추가: Format::Zip | |
| 94 | 추가: ); | |
| 81 | 95 | screen.extract(&output); |
| 82 | 삭제: assert_eq!(fs::read(output.join("content.txt")).unwrap(), b"Zipelo real worker flow\n"); | |
| 96 | 추가: assert_eq!( | |
| 97 | 추가: fs::read(output.join("content.txt")).unwrap(), | |
| 98 | 추가: b"Zipelo real worker flow\n" | |
| 99 | 추가: ); | |
| 83 | 100 | assert_eq!(fs::read(archive).unwrap(), original); |
| 84 | 101 | assert_reaped(&observed); |
| 85 | 102 | } |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | # 앱 화면 흐름 시험 |
| 2 | 2 | |
| 3 | 삭제: 가짜 작업자는 계약 revision 2의 의미를 따르는 프론트엔드 어댑터임. 바이너리 codec, 실제 프로세스 실행, 파일 읽기와 쓰기, 암호 해독은 수행하지 않음. 실제 codec은 backend 소유이며 이 PR에서 중복 구현하지 않음. | |
| 3 | 추가: 가짜 작업자는 합의된 계약의 의미를 따르는 프론트엔드 어댑터임. revision 3의 충돌 요청과 응답은 가짜 작업자로 검증함. 실제 StartInteractive와 화면 버튼의 파일 기반 통합 시험은 tests/rust-app-real-worker/conflict_flows.rs에서 별도로 실행함. 바이너리 codec, 실제 프로세스 실행, 파일 읽기와 쓰기, 암호 해독은 수행하지 않음. 실제 codec은 backend 소유이며 이 PR에서 중복 구현하지 않음. | |
| 4 | 4 | |
| 5 | 5 | `python3 tests/ci/run_rust.py local`은 기존 시험과 새 `archive_ui` 시험을 all-features로 실행함. Windows 결과는 교차 빌드이며 Windows 실제 실행은 별도 확인해야 함. |
| 6 | 6 |
| @@ -246,6 +246,7 @@ impl Connection for CaptureConnection { | ||
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 추가: Command::ConflictReply { .. } => return Err("충돌 선택은 상황 명령으로 확인함".into()), | |
| 249 | 250 | Command::Password { .. } => self.finish(false), |
| 250 | 251 | Command::Cancel => { |
| 251 | 252 | self.event(Event::CancelAck { |
| @@ -0,0 +1,52 @@ | ||
| 1 | 추가: use super::*; | |
| 2 | 추가: | |
| 3 | 추가: #[test] | |
| 4 | 추가: fn conflict_adapter_preserves_sizes_names_ids_and_choices() { | |
| 5 | 추가: let required = || wire::Message::ConflictRequired { | |
| 6 | 추가: challenge_id: 53, | |
| 7 | 추가: entry_id: 7, | |
| 8 | 추가: relative_name: "사진/기록.txt".into(), | |
| 9 | 추가: incoming_size: u64::MAX, | |
| 10 | 추가: existing_size: 1 << 34, | |
| 11 | 추가: }; | |
| 12 | 추가: match event_to_ui(required(), Some(wire::ActionKind::Extract)).unwrap() { | |
| 13 | 추가: ui::Event::ConflictRequired(c) => { | |
| 14 | 추가: assert_eq!(c.challenge_id, 53); | |
| 15 | 추가: assert_eq!(c.entry_id, 7); | |
| 16 | 추가: assert_eq!(c.relative_name, "사진/기록.txt"); | |
| 17 | 추가: assert_eq!(c.incoming_size, u64::MAX); | |
| 18 | 추가: assert_eq!(c.existing_size, 1 << 34); | |
| 19 | 추가: } | |
| 20 | 추가: _ => panic!("충돌 요청 변환 누락"), | |
| 21 | 추가: } | |
| 22 | 추가: for expected in [ | |
| 23 | 추가: None, | |
| 24 | 추가: Some(wire::ActionKind::List), | |
| 25 | 추가: Some(wire::ActionKind::CreateZip), | |
| 26 | 추가: ] { | |
| 27 | 추가: assert!(event_to_ui(required(), expected).is_err()); | |
| 28 | 추가: } | |
| 29 | 추가: for choice in [ | |
| 30 | 추가: ui::ConflictChoice::Overwrite, | |
| 31 | 추가: ui::ConflictChoice::Skip, | |
| 32 | 추가: ui::ConflictChoice::Rename, | |
| 33 | 추가: ] { | |
| 34 | 추가: match event_to_ui( | |
| 35 | 추가: wire::Message::ConflictResolved { | |
| 36 | 추가: entry_id: 7, | |
| 37 | 추가: relative_name: "사진/기록 (1).txt".into(), | |
| 38 | 추가: choice: conflict_to_wire(choice), | |
| 39 | 추가: }, | |
| 40 | 추가: Some(wire::ActionKind::Extract), | |
| 41 | 추가: ) | |
| 42 | 추가: .unwrap() | |
| 43 | 추가: { | |
| 44 | 추가: ui::Event::ConflictResolved(r) => { | |
| 45 | 추가: assert_eq!(r.choice, choice); | |
| 46 | 추가: assert_eq!(r.entry_id, 7); | |
| 47 | 추가: assert_eq!(r.relative_name, "사진/기록 (1).txt"); | |
| 48 | 추가: } | |
| 49 | 추가: _ => panic!("충돌 결과 변환 누락"), | |
| 50 | 추가: } | |
| 51 | 추가: } | |
| 52 | 추가: } |
| @@ -0,0 +1,291 @@ | ||
| 1 | 추가: use super::*; | |
| 2 | 추가: use std::collections::BTreeSet; | |
| 3 | 추가: use zipelo_ui_memory_app::archive_present as present; | |
| 4 | 추가: | |
| 5 | 추가: fn waiting() -> (Model, FakeFactory) { | |
| 6 | 추가: let mut factory = FakeFactory::default(); | |
| 7 | 추가: let mut model = Model::default(); | |
| 8 | 추가: list(&mut model, &mut factory); | |
| 9 | 추가: factory.state.borrow_mut().manual = true; | |
| 10 | 추가: assert!(model.extract(path("output"), false, None, &mut factory)); | |
| 11 | 추가: factory | |
| 12 | 추가: .state | |
| 13 | 추가: .borrow_mut() | |
| 14 | 추가: .frame(Event::Accepted { encryption: false }); | |
| 15 | 추가: ask(&mut model, &factory, 29); | |
| 16 | 추가: (model, factory) | |
| 17 | 추가: } | |
| 18 | 추가: | |
| 19 | 추가: fn ask(model: &mut Model, factory: &FakeFactory, challenge_id: u64) { | |
| 20 | 추가: factory | |
| 21 | 추가: .state | |
| 22 | 추가: .borrow_mut() | |
| 23 | 추가: .frame(Event::ConflictRequired(Conflict { | |
| 24 | 추가: challenge_id, | |
| 25 | 추가: entry_id: 0, | |
| 26 | 추가: relative_name: "읽어주세요.txt".into(), | |
| 27 | 추가: incoming_size: 31, | |
| 28 | 추가: existing_size: 128, | |
| 29 | 추가: })); | |
| 30 | 추가: for _ in 0..8 { | |
| 31 | 추가: model.poll(); | |
| 32 | 추가: } | |
| 33 | 추가: } | |
| 34 | 추가: | |
| 35 | 추가: #[test] | |
| 36 | 추가: fn each_choice_sends_one_scoped_reply_and_does_not_claim_a_saved_file() { | |
| 37 | 추가: for choice in [ | |
| 38 | 추가: ConflictChoice::Overwrite, | |
| 39 | 추가: ConflictChoice::Skip, | |
| 40 | 추가: ConflictChoice::Rename, | |
| 41 | 추가: ] { | |
| 42 | 추가: for apply in [false, true] { | |
| 43 | 추가: let (mut model, factory) = waiting(); | |
| 44 | 추가: assert_eq!(model.conflict.as_ref().unwrap().existing_size, 128); | |
| 45 | 추가: assert!(model.resolve_conflict(choice, apply)); | |
| 46 | 추가: assert!(model.conflict.is_none()); | |
| 47 | 추가: assert!(model.outputs.is_empty()); | |
| 48 | 추가: assert!(!model.resolve_conflict(choice, apply)); | |
| 49 | 추가: assert_eq!( | |
| 50 | 추가: factory.state.borrow().conflict_replies, | |
| 51 | 추가: vec![(29, choice, apply)] | |
| 52 | 추가: ); | |
| 53 | 추가: assert_eq!( | |
| 54 | 추가: factory.state.borrow().requests.last(), | |
| 55 | 추가: Some(&(1, "conflict")) | |
| 56 | 추가: ); | |
| 57 | 추가: } | |
| 58 | 추가: } | |
| 59 | 추가: } | |
| 60 | 추가: | |
| 61 | 추가: #[test] | |
| 62 | 추가: fn cancellation_clears_question_and_rejects_a_late_click() { | |
| 63 | 추가: let (mut model, factory) = waiting(); | |
| 64 | 추가: model.cancel(); | |
| 65 | 추가: assert!(model.conflict.is_none()); | |
| 66 | 추가: assert!(!model.resolve_conflict(ConflictChoice::Overwrite, true)); | |
| 67 | 추가: ask(&mut model, &factory, 30); | |
| 68 | 추가: assert!(model.conflict.is_none()); | |
| 69 | 추가: assert!(factory.state.borrow().conflict_replies.is_empty()); | |
| 70 | 추가: } | |
| 71 | 추가: | |
| 72 | 추가: #[test] | |
| 73 | 추가: fn duplicate_challenge_and_duplicate_resolution_are_rejected() { | |
| 74 | 추가: let (mut model, factory) = waiting(); | |
| 75 | 추가: assert!(model.resolve_conflict(ConflictChoice::Skip, false)); | |
| 76 | 추가: ask(&mut model, &factory, 29); | |
| 77 | 추가: assert!(model.error.is_some()); | |
| 78 | 추가: let (mut model, factory) = waiting(); | |
| 79 | 추가: let resolution = Resolution { | |
| 80 | 추가: entry_id: 0, | |
| 81 | 추가: relative_name: "읽어주세요.txt".into(), | |
| 82 | 추가: choice: ConflictChoice::Skip, | |
| 83 | 추가: }; | |
| 84 | 추가: for _ in 0..2 { | |
| 85 | 추가: factory | |
| 86 | 추가: .state | |
| 87 | 추가: .borrow_mut() | |
| 88 | 추가: .frame(Event::ConflictResolved(resolution.clone())); | |
| 89 | 추가: } | |
| 90 | 추가: for _ in 0..8 { | |
| 91 | 추가: model.poll(); | |
| 92 | 추가: } | |
| 93 | 추가: assert!(model.error.is_some()); | |
| 94 | 추가: } | |
| 95 | 추가: | |
| 96 | 추가: fn completed(created_count: u64) -> Terminal { | |
| 97 | 추가: Terminal { | |
| 98 | 추가: outcome: Outcome::Completed, | |
| 99 | 추가: error: None, | |
| 100 | 추가: publication: if created_count == 0 { | |
| 101 | 추가: Publication::None | |
| 102 | 추가: } else { | |
| 103 | 추가: Publication::Complete | |
| 104 | 추가: }, | |
| 105 | 추가: created_count, | |
| 106 | 추가: retained_partial_count: 0, | |
| 107 | 추가: durability: if created_count == 0 { | |
| 108 | 추가: Durability::NotApplicable | |
| 109 | 추가: } else { | |
| 110 | 추가: Durability::Synced | |
| 111 | 추가: }, | |
| 112 | 추가: cleanup: Cleanup::Complete, | |
| 113 | 추가: } | |
| 114 | 추가: } | |
| 115 | 추가: | |
| 116 | 추가: #[test] | |
| 117 | 추가: fn auto_applied_results_adjust_targets_but_created_reports_confirm_saves() { | |
| 118 | 추가: for choice in [ | |
| 119 | 추가: ConflictChoice::Overwrite, | |
| 120 | 추가: ConflictChoice::Skip, | |
| 121 | 추가: ConflictChoice::Rename, | |
| 122 | 추가: ] { | |
| 123 | 추가: let (mut model, factory) = waiting(); | |
| 124 | 추가: assert!(model.resolve_conflict(choice, true)); | |
| 125 | 추가: let name = if choice == ConflictChoice::Rename { | |
| 126 | 추가: "읽어주세요 (1).txt" | |
| 127 | 추가: } else { | |
| 128 | 추가: "읽어주세요.txt" | |
| 129 | 추가: }; | |
| 130 | 추가: factory | |
| 131 | 추가: .state | |
| 132 | 추가: .borrow_mut() | |
| 133 | 추가: .frame(Event::ConflictResolved(Resolution { | |
| 134 | 추가: entry_id: 0, | |
| 135 | 추가: relative_name: name.into(), | |
| 136 | 추가: choice, | |
| 137 | 추가: })); | |
| 138 | 추가: for _ in 0..8 { | |
| 139 | 추가: model.poll(); | |
| 140 | 추가: } | |
| 141 | 추가: assert!(model.outputs.is_empty()); | |
| 142 | 추가: let targets = ["읽어주세요.txt".to_owned()].into_iter().collect(); | |
| 143 | 추가: let targets = | |
| 144 | 추가: present::resolved_targets(Some(&targets), &model.entries, None, &model.resolutions) | |
| 145 | 추가: .unwrap(); | |
| 146 | 추가: assert_eq!(targets.len(), usize::from(choice != ConflictChoice::Skip)); | |
| 147 | 추가: let count = u64::from(choice != ConflictChoice::Skip); | |
| 148 | 추가: let terminal = completed(count); | |
| 149 | 추가: if count != 0 { | |
| 150 | 추가: assert!( | |
| 151 | 추가: present::publication_warnings( | |
| 152 | 추가: Some(&terminal), | |
| 153 | 추가: true, | |
| 154 | 추가: Some(&targets), | |
| 155 | 추가: &BTreeSet::new(), | |
| 156 | 추가: &[] | |
| 157 | 추가: ) | |
| 158 | 추가: .contains(&present::UNCERTAIN) | |
| 159 | 추가: ); | |
| 160 | 추가: factory.state.borrow_mut().frame(Event::Output { | |
| 161 | 추가: entry_id: Some(0), | |
| 162 | 추가: relative_name: name.into(), | |
| 163 | 추가: disposition: Disposition::Created, | |
| 164 | 추가: }); | |
| 165 | 추가: } | |
| 166 | 추가: factory | |
| 167 | 추가: .state | |
| 168 | 추가: .borrow_mut() | |
| 169 | 추가: .frame(Event::Terminal(terminal.clone())); | |
| 170 | 추가: factory.state.borrow_mut().queue.extend([ | |
| 171 | 추가: HostEvent::StdoutEof, | |
| 172 | 추가: HostEvent::StderrEof, | |
| 173 | 추가: HostEvent::Exited { success: true }, | |
| 174 | 추가: ]); | |
| 175 | 추가: pump(&mut model); | |
| 176 | 추가: assert!(model.confirmed); | |
| 177 | 추가: assert!(model.conflict.is_none()); | |
| 178 | 추가: assert!( | |
| 179 | 추가: present::publication_warnings( | |
| 180 | 추가: Some(&terminal), | |
| 181 | 추가: model.confirmed, | |
| 182 | 추가: Some(&targets), | |
| 183 | 추가: &BTreeSet::new(), | |
| 184 | 추가: &model.outputs | |
| 185 | 추가: ) | |
| 186 | 추가: .is_empty() | |
| 187 | 추가: ); | |
| 188 | 추가: } | |
| 189 | 추가: } | |
| 190 | 추가: | |
| 191 | 추가: #[test] | |
| 192 | 추가: fn skipped_files_still_allow_created_directories_to_be_counted() { | |
| 193 | 추가: let terminal = completed(1); | |
| 194 | 추가: assert!( | |
| 195 | 추가: present::publication_warnings( | |
| 196 | 추가: Some(&terminal), | |
| 197 | 추가: true, | |
| 198 | 추가: Some(&BTreeSet::new()), | |
| 199 | 추가: &["사진".into()].into_iter().collect(), | |
| 200 | 추가: &[("사진".into(), Disposition::Created)], | |
| 201 | 추가: ) | |
| 202 | 추가: .is_empty() | |
| 203 | 추가: ); | |
| 204 | 추가: } | |
| 205 | 추가: | |
| 206 | 추가: #[cfg(all(feature = "ui-fixture", debug_assertions))] | |
| 207 | 추가: #[test] | |
| 208 | 추가: fn conflict_modal_buttons_and_escape_use_the_pending_question() { | |
| 209 | 추가: use eframe::egui::{self, epaint::Shape}; | |
| 210 | 추가: use zipelo_ui_memory_app::archive_screen::{ArchiveApp, scenarios}; | |
| 211 | 추가: for label in [ | |
| 212 | 추가: "덮어쓰기", | |
| 213 | 추가: "건너뛰기", | |
| 214 | 추가: "이름 바꿔 저장", | |
| 215 | 추가: "작업 취소", | |
| 216 | 추가: "escape", | |
| 217 | 추가: ] { | |
| 218 | 추가: let ctx = egui::Context::default(); | |
| 219 | 추가: let mut app = scenarios::parse("conflict-choice").unwrap().build(); | |
| 220 | 추가: let frame = |app: &mut ArchiveApp, events| { | |
| 221 | 추가: let mut output = ctx.run_ui( | |
| 222 | 추가: egui::RawInput { | |
| 223 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 224 | 추가: egui::Pos2::ZERO, | |
| 225 | 추가: egui::vec2(760.0, 540.0), | |
| 226 | 추가: )), | |
| 227 | 추가: events, | |
| 228 | 추가: ..Default::default() | |
| 229 | 추가: }, | |
| 230 | 추가: |ui| app.show(ui), | |
| 231 | 추가: ); | |
| 232 | 추가: output.textures_delta.clear(); | |
| 233 | 추가: output | |
| 234 | 추가: }; | |
| 235 | 추가: fn labels(shape: &Shape, output: &mut Vec<(String, egui::Pos2)>) { | |
| 236 | 추가: match shape { | |
| 237 | 추가: Shape::Text(t) => { | |
| 238 | 추가: output.push((t.galley.text().into(), t.pos + t.galley.rect.size() / 2.0)) | |
| 239 | 추가: } | |
| 240 | 추가: Shape::Vec(shapes) => { | |
| 241 | 추가: for shape in shapes { | |
| 242 | 추가: labels(shape, output); | |
| 243 | 추가: } | |
| 244 | 추가: } | |
| 245 | 추가: _ => {} | |
| 246 | 추가: } | |
| 247 | 추가: } | |
| 248 | 추가: let mut texts = Vec::new(); | |
| 249 | 추가: for _ in 0..3 { | |
| 250 | 추가: texts.clear(); | |
| 251 | 추가: for shape in frame(&mut app, vec![]).shapes { | |
| 252 | 추가: labels(&shape.shape, &mut texts); | |
| 253 | 추가: } | |
| 254 | 추가: } | |
| 255 | 추가: if label == "escape" { | |
| 256 | 추가: frame( | |
| 257 | 추가: &mut app, | |
| 258 | 추가: vec![egui::Event::Key { | |
| 259 | 추가: key: egui::Key::Escape, | |
| 260 | 추가: physical_key: None, | |
| 261 | 추가: pressed: true, | |
| 262 | 추가: repeat: false, | |
| 263 | 추가: modifiers: egui::Modifiers::NONE, | |
| 264 | 추가: }], | |
| 265 | 추가: ); | |
| 266 | 추가: } else { | |
| 267 | 추가: let point = texts.iter().find(|(text, _)| text == label).unwrap().1; | |
| 268 | 추가: for pressed in [true, false] { | |
| 269 | 추가: frame( | |
| 270 | 추가: &mut app, | |
| 271 | 추가: vec![ | |
| 272 | 추가: egui::Event::PointerMoved(point), | |
| 273 | 추가: egui::Event::PointerButton { | |
| 274 | 추가: pos: point, | |
| 275 | 추가: button: egui::PointerButton::Primary, | |
| 276 | 추가: pressed, | |
| 277 | 추가: modifiers: egui::Modifiers::NONE, | |
| 278 | 추가: }, | |
| 279 | 추가: ], | |
| 280 | 추가: ); | |
| 281 | 추가: } | |
| 282 | 추가: } | |
| 283 | 추가: assert!(app.model.conflict.is_none(), "{label}"); | |
| 284 | 추가: assert!(app.model.busy()); | |
| 285 | 추가: assert!(app.model.outputs.is_empty()); | |
| 286 | 추가: assert_eq!( | |
| 287 | 추가: app.model.cancellation_requested(), | |
| 288 | 추가: matches!(label, "작업 취소" | "escape") | |
| 289 | 추가: ); | |
| 290 | 추가: } | |
| 291 | 추가: } |
| @@ -6,6 +6,7 @@ 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 conflict_replies: Vec<(u64, ConflictChoice, bool)>, | |
| 9 | 10 | /// 마지막으로 받은 암호 원문. 화면에서 입력한 암호가 그대로 전달됐는지 확인할 때 씀. |
| 10 | 11 | pub password: Vec<u8>, |
| 11 | 12 | pub job: u64, |
| @@ -184,6 +185,15 @@ impl Connection for FakeConnection { | ||
| 184 | 185 | s.complete_action(); |
| 185 | 186 | } |
| 186 | 187 | } |
| 188 | 추가: Command::ConflictReply { | |
| 189 | 추가: challenge_id, | |
| 190 | 추가: choice, | |
| 191 | 추가: apply_to_remaining, | |
| 192 | 추가: } => { | |
| 193 | 추가: s.requests.push((request.sequence, "conflict")); | |
| 194 | 추가: s.conflict_replies | |
| 195 | 추가: .push((challenge_id, choice, apply_to_remaining)); | |
| 196 | 추가: } | |
| 187 | 197 | Command::Cancel => { |
| 188 | 198 | s.requests.push((request.sequence, "cancel")); |
| 189 | 199 | if !s.manual { |
| @@ -1,3 +1,4 @@ | ||
| 1 | 추가: mod conflicts; | |
| 1 | 2 | #[cfg(feature = "ui")] |
| 2 | 3 | mod dialogs; |
| 3 | 4 | mod fake; |
| @@ -100,6 +100,12 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() { | ||
| 100 | 100 | "uninstall-settings-error" => "Windows 설정을 열지 못했습니다", |
| 101 | 101 | "uninstall-ubuntu-missing" => "이전 앱을 복원할 수 없습니다", |
| 102 | 102 | "uninstall-ubuntu-unknown-user" => "사용자 기본 앱 설정은 변경하지 않습니다", |
| 103 | 추가: "conflict-choice" | "conflict-apply" | "gzip-conflict-choice" => { | |
| 104 | 추가: "나머지 파일에도 같게 적용" | |
| 105 | 추가: } | |
| 106 | 추가: "extract-skipped" => "모든 파일을 건너뛰었습니다", | |
| 107 | 추가: "extract-rename-failed" => "아무 파일도 풀지 않았습니다", | |
| 108 | 추가: "extract-renamed" => "이름 바꿔 저장: 읽어주세요 (1).txt", | |
| 103 | 109 | "empty" => "TAR.BZ2, TAR.XZ", |
| 104 | 110 | "tar-bz2" | "tar-xz" => "읽어주세요.txt", |
| 105 | 111 | "folder-empty" => "이 폴더는 비어 있습니다", |
| @@ -124,6 +130,10 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() { | ||
| 124 | 130 | _ => "읽어주세요.txt", |
| 125 | 131 | }; |
| 126 | 132 | assert!(labels.contains(expected), "{}: {labels}", scenario.name); |
| 133 | 추가: if scenario.name == "extract-rename-failed" { | |
| 134 | 추가: assert!(labels.contains("파일을 읽거나 쓰지 못했습니다"), "{labels}"); | |
| 135 | 추가: assert!(!labels.contains("이름 바꿔 저장:"), "{labels}"); | |
| 136 | 추가: } | |
| 127 | 137 | if matches!(scenario.name, "tar-bz2" | "tar-xz") { |
| 128 | 138 | assert!(app.model.entries.iter().all(|entry| !entry.encrypted)); |
| 129 | 139 | assert_eq!( |
| @@ -257,3 +267,90 @@ fn uninstall_previews_match_packaged_notices_and_do_not_start_jobs() { | ||
| 257 | 267 | output.textures_delta.clear(); |
| 258 | 268 | } |
| 259 | 269 | } |
| 270 | 추가: | |
| 271 | 추가: fn result_labels( | |
| 272 | 추가: app: &mut zipelo_ui_memory_app::archive_screen::ArchiveApp, | |
| 273 | 추가: size: egui::Vec2, | |
| 274 | 추가: ) -> String { | |
| 275 | 추가: let ctx = egui::Context::default(); | |
| 276 | 추가: let mut labels = String::new(); | |
| 277 | 추가: for _ in 0..3 { | |
| 278 | 추가: let mut output = ctx.run_ui( | |
| 279 | 추가: egui::RawInput { | |
| 280 | 추가: screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, size)), | |
| 281 | 추가: ..Default::default() | |
| 282 | 추가: }, | |
| 283 | 추가: |ui| app.show(ui), | |
| 284 | 추가: ); | |
| 285 | 추가: labels = text(&output.shapes); | |
| 286 | 추가: output.textures_delta.clear(); | |
| 287 | 추가: } | |
| 288 | 추가: labels | |
| 289 | 추가: } | |
| 290 | 추가: | |
| 291 | 추가: #[test] | |
| 292 | 추가: fn rename_without_created_output_never_claims_saved_name() { | |
| 293 | 추가: use zipelo_ui_memory_app::archive_ui::*; | |
| 294 | 추가: for size in [egui::vec2(1060.0, 720.0), egui::vec2(760.0, 540.0)] { | |
| 295 | 추가: for disposition in [ | |
| 296 | 추가: None, | |
| 297 | 추가: Some(Disposition::PartialRetained), | |
| 298 | 추가: Some(Disposition::Removed), | |
| 299 | 추가: Some(Disposition::CommitUncertain), | |
| 300 | 추가: ] { | |
| 301 | 추가: let mut app = scenarios::parse("extract-renamed").unwrap().build(); | |
| 302 | 추가: app.model.outputs = disposition | |
| 303 | 추가: .into_iter() | |
| 304 | 추가: .map(|d| ("읽어주세요 (1).txt".into(), d)) | |
| 305 | 추가: .collect(); | |
| 306 | 추가: app.model.terminal = Some(Terminal { | |
| 307 | 추가: outcome: Outcome::Failed, | |
| 308 | 추가: error: Some(ErrorCode::Io), | |
| 309 | 추가: publication: if disposition.is_none() { | |
| 310 | 추가: Publication::None | |
| 311 | 추가: } else { | |
| 312 | 추가: Publication::Uncertain | |
| 313 | 추가: }, | |
| 314 | 추가: created_count: 0, | |
| 315 | 추가: retained_partial_count: 0, | |
| 316 | 추가: durability: Durability::NotApplicable, | |
| 317 | 추가: cleanup: Cleanup::Complete, | |
| 318 | 추가: }); | |
| 319 | 추가: let labels = result_labels(&mut app, size); | |
| 320 | 추가: assert!(labels.contains("파일을 읽거나 쓰지 못했습니다"), "{labels}"); | |
| 321 | 추가: if disposition.is_none() { | |
| 322 | 추가: assert!(labels.contains("아무 파일도 풀지 않았습니다"), "{labels}"); | |
| 323 | 추가: } | |
| 324 | 추가: assert!( | |
| 325 | 추가: !labels.contains("이름 바꿔 저장: 읽어주세요 (1).txt"), | |
| 326 | 추가: "{labels}" | |
| 327 | 추가: ); | |
| 328 | 추가: } | |
| 329 | 추가: } | |
| 330 | 추가: } | |
| 331 | 추가: | |
| 332 | 추가: #[test] | |
| 333 | 추가: fn rename_saved_before_later_failure_remains_reported() { | |
| 334 | 추가: use zipelo_ui_memory_app::archive_ui::*; | |
| 335 | 추가: for size in [egui::vec2(1060.0, 720.0), egui::vec2(760.0, 540.0)] { | |
| 336 | 추가: let mut app = scenarios::parse("extract-renamed").unwrap().build(); | |
| 337 | 추가: app.model.resolutions.push(Resolution { | |
| 338 | 추가: entry_id: 2, | |
| 339 | 추가: relative_name: "여행 일정 (1).pdf".into(), | |
| 340 | 추가: choice: ConflictChoice::Rename, | |
| 341 | 추가: }); | |
| 342 | 추가: app.model.terminal.as_mut().unwrap().outcome = Outcome::Failed; | |
| 343 | 추가: app.model.terminal.as_mut().unwrap().error = Some(ErrorCode::Io); | |
| 344 | 추가: app.model.terminal.as_mut().unwrap().publication = Publication::Partial; | |
| 345 | 추가: let labels = result_labels(&mut app, size); | |
| 346 | 추가: assert!( | |
| 347 | 추가: labels.contains("이름 바꿔 저장: 읽어주세요 (1).txt"), | |
| 348 | 추가: "{labels}" | |
| 349 | 추가: ); | |
| 350 | 추가: assert!( | |
| 351 | 추가: !labels.contains("이름 바꿔 저장: 여행 일정 (1).pdf"), | |
| 352 | 추가: "{labels}" | |
| 353 | 추가: ); | |
| 354 | 추가: assert!(labels.contains("파일을 읽거나 쓰지 못했습니다"), "{labels}"); | |
| 355 | 추가: } | |
| 356 | 추가: } |
| @@ -21,6 +21,12 @@ macro_rules! catalog { | ||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | catalog! { |
| 24 | 추가: "gzip-conflict-choice" => "단일 GZ 파일의 충돌 선택", | |
| 25 | 추가: "conflict-choice" => "같은 이름 파일의 세 가지 처리 선택", | |
| 26 | 추가: "conflict-apply" => "남은 충돌에 같은 선택 적용", | |
| 27 | 추가: "extract-skipped" => "모든 파일을 건너뛴 정상 완료", | |
| 28 | 추가: "extract-renamed" => "이름을 바꿔 저장한 완료 결과", | |
| 29 | 추가: "extract-rename-failed" => "새 이름을 정한 뒤 저장 전 I/O 실패", | |
| 24 | 30 | "empty" => "빈 첫 화면", |
| 25 | 31 | "archive" => "폴더와 파일이 있는 압축파일", |
| 26 | 32 | "tar-bz2" => "TAR.BZ2 목록과 자동 해제 폴더", |
| @@ -223,7 +229,7 @@ impl Scenario { | ||
| 223 | 229 | return app; |
| 224 | 230 | } |
| 225 | 231 | let archive = base.join(match self.name { |
| 226 | 삭제: "gzip-conflict" => "여행 자료.gz", | |
| 232 | 추가: "gzip-conflict" | "gzip-conflict-choice" => "여행 자료.gz", | |
| 227 | 233 | "tar-bz2" => "여행 자료.TAR.BZ2", |
| 228 | 234 | "tar-xz" => "여행 자료.TaR.Xz", |
| 229 | 235 | _ => "여행 자료.zip", |
| @@ -301,7 +307,7 @@ impl Scenario { | ||
| 301 | 307 | } |
| 302 | 308 | let creating = self.name.starts_with("create-") || self.name == "password-create"; |
| 303 | 309 | let listing_error = matches!(self.name, "unsupported" | "damaged"); |
| 304 | 삭제: if self.name == "gzip-conflict" { | |
| 310 | 추가: if matches!(self.name, "gzip-conflict" | "gzip-conflict-choice") { | |
| 305 | 311 | app.model.list_id.as_mut().unwrap().format = Format::Gzip; |
| 306 | 312 | app.model.entries = vec![Entry { |
| 307 | 313 | id: 0, |
| @@ -328,12 +334,13 @@ impl Scenario { | ||
| 328 | 334 | destination: app.destination.clone(), |
| 329 | 335 | selection: Selection::All, |
| 330 | 336 | list_id: app.model.list_id.clone().unwrap(), |
| 331 | 삭제: gzip_output_name: (self.name == "gzip-conflict").then(|| app.gzip_name.clone()), | |
| 337 | 추가: gzip_output_name: (matches!(self.name, "gzip-conflict" | "gzip-conflict-choice")) | |
| 338 | 추가: .then(|| app.gzip_name.clone()), | |
| 332 | 339 | } |
| 333 | 340 | }; |
| 334 | 341 | app.targets = Some(if creating { |
| 335 | 342 | BTreeSet::from(["여행 자료.zip".into()]) |
| 336 | 삭제: } else if self.name == "gzip-conflict" { | |
| 343 | 추가: } else if matches!(self.name, "gzip-conflict" | "gzip-conflict-choice") { | |
| 337 | 344 | BTreeSet::from(["여행 자료".into()]) |
| 338 | 345 | } else { |
| 339 | 346 | BTreeSet::from([ |
| @@ -343,11 +350,87 @@ impl Scenario { | ||
| 343 | 350 | "사진/풍경.jpg".into(), |
| 344 | 351 | ]) |
| 345 | 352 | }); |
| 353 | 추가: if matches!( | |
| 354 | 추가: self.name, | |
| 355 | 추가: "extract-skipped" | "extract-renamed" | "extract-rename-failed" | |
| 356 | 추가: ) { | |
| 357 | 추가: app.targets = Some(["읽어주세요.txt".into()].into_iter().collect()); | |
| 358 | 추가: app.directories.clear(); | |
| 359 | 추가: } | |
| 346 | 360 | assert!(app.start(request)); |
| 347 | 361 | { |
| 348 | 362 | let mut state = state.borrow_mut(); |
| 349 | 363 | state.frame(Event::Accepted { encryption: true }); |
| 350 | 364 | match self.name { |
| 365 | 추가: "conflict-choice" | "conflict-apply" | "gzip-conflict-choice" => { | |
| 366 | 추가: state.frame(Event::ConflictRequired(Conflict { | |
| 367 | 추가: challenge_id: 29, | |
| 368 | 추가: entry_id: if self.name == "gzip-conflict-choice" { | |
| 369 | 추가: 0 | |
| 370 | 추가: } else { | |
| 371 | 추가: 1 | |
| 372 | 추가: }, | |
| 373 | 추가: relative_name: if self.name == "gzip-conflict-choice" { | |
| 374 | 추가: "여행 자료" | |
| 375 | 추가: } else { | |
| 376 | 추가: "읽어주세요.txt" | |
| 377 | 추가: } | |
| 378 | 추가: .into(), | |
| 379 | 추가: incoming_size: 1_287_952, | |
| 380 | 추가: existing_size: 2048, | |
| 381 | 추가: })); | |
| 382 | 추가: } | |
| 383 | 추가: "extract-skipped" | "extract-renamed" | "extract-rename-failed" => { | |
| 384 | 추가: let failed = self.name == "extract-rename-failed"; | |
| 385 | 추가: let skip = self.name == "extract-skipped"; | |
| 386 | 추가: let name = if skip { | |
| 387 | 추가: "읽어주세요.txt" | |
| 388 | 추가: } else { | |
| 389 | 추가: "읽어주세요 (1).txt" | |
| 390 | 추가: }; | |
| 391 | 추가: state.frame(Event::ConflictResolved(Resolution { | |
| 392 | 추가: entry_id: 1, | |
| 393 | 추가: relative_name: name.into(), | |
| 394 | 추가: choice: if skip { | |
| 395 | 추가: ConflictChoice::Skip | |
| 396 | 추가: } else { | |
| 397 | 추가: ConflictChoice::Rename | |
| 398 | 추가: }, | |
| 399 | 추가: })); | |
| 400 | 추가: if !skip && !failed { | |
| 401 | 추가: state.frame(Event::Output { | |
| 402 | 추가: entry_id: Some(1), | |
| 403 | 추가: relative_name: name.into(), | |
| 404 | 추가: disposition: Disposition::Created, | |
| 405 | 추가: }); | |
| 406 | 추가: } | |
| 407 | 추가: state.frame(Event::Terminal(Terminal { | |
| 408 | 추가: outcome: if failed { | |
| 409 | 추가: Outcome::Failed | |
| 410 | 추가: } else { | |
| 411 | 추가: Outcome::Completed | |
| 412 | 추가: }, | |
| 413 | 추가: error: failed.then_some(ErrorCode::Io), | |
| 414 | 추가: publication: if skip || failed { | |
| 415 | 추가: Publication::None | |
| 416 | 추가: } else { | |
| 417 | 추가: Publication::Complete | |
| 418 | 추가: }, | |
| 419 | 추가: created_count: u64::from(!skip && !failed), | |
| 420 | 추가: retained_partial_count: 0, | |
| 421 | 추가: durability: if skip || failed { | |
| 422 | 추가: Durability::NotApplicable | |
| 423 | 추가: } else { | |
| 424 | 추가: Durability::Synced | |
| 425 | 추가: }, | |
| 426 | 추가: cleanup: Cleanup::Complete, | |
| 427 | 추가: })); | |
| 428 | 추가: state.queue.extend([ | |
| 429 | 추가: HostEvent::StdoutEof, | |
| 430 | 추가: HostEvent::StderrEof, | |
| 431 | 추가: HostEvent::Exited { success: true }, | |
| 432 | 추가: ]); | |
| 433 | 추가: } | |
| 351 | 434 | "password" | "password-retry" | "password-create" => { |
| 352 | 435 | state.frame(Event::PasswordRequired { |
| 353 | 436 | challenge_id: 17, |
| @@ -450,6 +533,10 @@ impl Scenario { | ||
| 450 | 533 | for _ in 0..64 { |
| 451 | 534 | app.model.poll(); |
| 452 | 535 | } |
| 536 | 추가: if self.name == "conflict-apply" { | |
| 537 | 추가: app.conflict_challenge = Some((app.model.job_id().unwrap(), 29)); | |
| 538 | 추가: app.conflict_apply = true; | |
| 539 | 추가: } | |
| 453 | 540 | if self.name == "extract-unsynced" { |
| 454 | 541 | app.details = true; |
| 455 | 542 | } |