team-ljyzipelo

공개

파일 충돌 선택 화면과 클라이언트 상태를 준비함

작성자
호시노 히나타
작성 시각
커밋
64ada4bb3553636297a916c948d874bb828fecb8
부모
6ee2815
이 시점의 파일 보기

변경된 파일 12개

+720-4
수정docs/ui-scenario-guide.md+9-0
@@ -93,3 +93,12 @@ python3 tests/ci/run_rust.py local
9393
9494화면에 새 창, 버튼, 메시지, 상태 또는 오류를 추가하거나 바꾸면 같은 PR에서 상황, 시험과 이 가이드를 갱신한다. 화면 변화가 없으면 PR 본문에 "UI 변경 없음"이라고 적는다. 사용자가 직접 올린 UI 변경에서 빠진 상황은 병합 뒤 프론트엔드 담당이 보완한다.
9595
96추가:
97추가: ## 파일 충돌 선택과 결과
98추가:
99추가: - conflict-choice: 파일 경로와 기존 크기, 새 크기 및 덮어쓰기, 건너뛰기, 이름 바꿔 저장을 확인합니다. Tab으로 이동하고 Space로 선택할 수 있으며 Escape 또는 작업 취소는 전체 작업을 취소합니다.
100추가: - conflict-apply: "나머지 파일에도 같게 적용"이 켜진 상태입니다. 현재 작업의 남은 일반 파일 충돌에만 적용하며 이름 바꿔 저장은 같은 폴더에 번호를 붙입니다.
101추가: - extract-skipped: 모든 파일을 건너뛴 정상 완료입니다. 생성된 파일이 없으며 저장 실패 경고가 없어야 합니다.
102추가: - extract-renamed: 실제 저장된 새 이름을 표시합니다. 이름 변경 결과만으로 저장 성공을 판정하지 않고 별도의 생성 보고와 완료 집계가 일치해야 합니다.
103추가:
104추가: 현재 충돌 화면과 클라이언트 연동은 준비 단계입니다. 작업자 런타임이 완성되기 전에는 실제 추출 요청을 기존 Start로 유지하며 StartInteractive를 보내지 않습니다. 위 명령은 실제 파일을 쓰지 않는 개발용 화면 미리보기입니다.
수정experiments/rust-ui-memory-app/src/archive_present.rs+28-0
@@ -130,6 +130,32 @@ pub fn target_files(
130130 Some(names)
131131}
132132
133추가: pub fn resolved_targets(
134추가: targets: Option<&BTreeSet<String>>,
135추가: entries: &[Entry],
136추가: gzip: Option<&str>,
137추가: resolutions: &[Resolution],
138추가: ) -> Option<BTreeSet<String>> {
139추가: let mut names = targets?.clone();
140추가: for resolution in resolutions {
141추가: let entry = entries
142추가: .iter()
143추가: .find(|entry| entry.id == resolution.entry_id)?;
144추가: let original = gzip.unwrap_or(&entry.name).replace('\\', "/");
145추가: if !names.remove(&original) {
146추가: return None;
147추가: }
148추가: }
149추가: for resolution in resolutions {
150추가: if resolution.choice != ConflictChoice::Skip
151추가: && !names.insert(resolution.relative_name.replace('\\', "/"))
152추가: {
153추가: return None;
154추가: }
155추가: }
156추가: Some(names)
157추가: }
158추가:
133159pub fn target_directories(entries: &[Entry], selection: &Selection) -> BTreeSet<String> {
134160 let mut directories = BTreeSet::new();
135161 for entry in entries.iter().filter(|entry| {
@@ -352,6 +378,8 @@ pub fn activity_text(model: &Model, creating: bool) -> &'static str {
352378 "마무리하는 중"
353379 } else if model.cancellation_requested() || model.cancel.is_some() {
354380 "취소하는 중..."
381추가: } else if model.conflict.is_some() {
382추가: "파일 충돌 선택 대기 중"
355383 } else if model.challenge.is_some() {
356384 "암호를 입력하세요"
357385 } else {
수정experiments/rust-ui-memory-app/src/archive_process.rs+55-0
@@ -114,6 +114,22 @@ convert_enum!(
114114 TooLate,
115115 Finished
116116);
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추가: );
117133fn list_to_wire(id: ui::ListId) -> wire::ListId {
118134 wire::ListId {
119135 catalog_version: id.catalog_version,
@@ -252,6 +268,32 @@ fn event_to_ui(
252268 attempt,
253269 encrypt: purpose == wire::PasswordPurpose::Encrypt,
254270 },
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추가: }
255297 wire::Message::Progress {
256298 stage,
257299 processed_bytes,
@@ -460,6 +502,15 @@ impl ui::Connection for ProcessConnection {
460502 })? = Some(start.action.kind());
461503 wire::Message::Start(start)
462504 }
505추가: ui::Command::ConflictReply {
506추가: challenge_id,
507추가: choice,
508추가: apply_to_remaining,
509추가: } => wire::Message::ConflictReply {
510추가: challenge_id,
511추가: choice: conflict_to_wire(choice),
512추가: apply_to_remaining,
513추가: },
463514 ui::Command::Cancel => wire::Message::Cancel,
464515 ui::Command::Password {
465516 challenge_id,
@@ -680,3 +731,7 @@ fn supervise(
680731 );
681732 }
682733}
734추가:
735추가: #[cfg(test)]
736추가: #[path = "../../../tests/rust-app-ui/conflict_codec.rs"]
737추가: mod conflict_codec_tests;
수정experiments/rust-ui-memory-app/src/archive_screen.rs+97-2
@@ -202,6 +202,8 @@ pub struct ArchiveApp {
202202 password_confirm: String,
203203 password_visible: bool,
204204 password_challenge: Option<u64>,
205추가: conflict_challenge: Option<(u64, u64)>,
206추가: conflict_apply: bool,
205207 aes256: bool,
206208 create: bool,
207209 selected_only: bool,
@@ -263,6 +265,8 @@ impl ArchiveApp {
263265 password_confirm: String::new(),
264266 password_visible: false,
265267 password_challenge: None,
268추가: conflict_challenge: None,
269추가: conflict_apply: false,
266270 aes256: false,
267271 create: false,
268272 selected_only: false,
@@ -1012,6 +1016,9 @@ impl ArchiveApp {
10121016 if self.model.challenge.is_some() {
10131017 self.password_dialog(&ctx, new_challenge);
10141018 }
1019추가: if self.model.conflict.is_some() && self.model.close == Close::Open {
1020추가: self.conflict_dialog(&ctx);
1021추가: }
10151022 self.close_dialog(&ctx);
10161023 self.picker_notice(&ctx);
10171024 if self.custom_frame {
@@ -1593,6 +1600,7 @@ impl ArchiveApp {
15931600 (self.create && !self.model.busy())
15941601 || self.picker.is_some()
15951602 || self.model.challenge.is_some()
1603추가: || self.model.conflict.is_some()
15961604 || self.model.close != Close::Open
15971605 }
15981606
@@ -1776,13 +1784,32 @@ impl ArchiveApp {
17761784 let t = self.model.terminal.clone();
17771785 let listing = matches!(self.last_request, Some(Start::List { .. }));
17781786 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();
17791806 let warnings = if listing {
17801807 Vec::new()
17811808 } else {
17821809 present::publication_warnings(
17831810 t.as_ref(),
17841811 self.model.confirmed,
1785삭제: self.targets.as_ref(),
1812추가: resolved_targets.as_ref(),
17861813 &self.directories,
17871814 &self.model.outputs,
17881815 )
@@ -1803,6 +1830,8 @@ impl ArchiveApp {
18031830 let title = if success {
18041831 if creating {
18051832 "ZIP 파일을 만들었습니다"
1833추가: } else if skipped > 0 && t.as_ref().is_some_and(|t| t.created_count == 0) {
1834추가: "모든 파일을 건너뛰었습니다"
18061835 } else {
18071836 "압축을 풀었습니다"
18081837 }
@@ -1846,7 +1875,7 @@ impl ArchiveApp {
18461875 .id_salt("result-message")
18471876 .max_height(max_height)
18481877 .show(ui, |ui| {
1849삭제: if success {
1878추가: if success && t.as_ref().is_some_and(|t| t.created_count > 0) {
18501879 let path = match self.last_request.as_ref() {
18511880 Some(Start::CreateZip { output_file, .. }) => {
18521881 output_file.display().to_string()
@@ -1866,6 +1895,21 @@ impl ArchiveApp {
18661895 creating,
18671896 ));
18681897 }
1898추가: if skipped > 0 {
1899추가: ui.label(format!("건너뛴 파일 {skipped}개"));
1900추가: }
1901추가: for resolution in self
1902추가: .model
1903추가: .resolutions
1904추가: .iter()
1905추가: .filter(|r| r.choice == ConflictChoice::Rename)
1906추가: {
1907추가: theme::bounded_text(
1908추가: ui,
1909추가: &format!("이름 바꿔 저장: {}", resolution.relative_name),
1910추가: ui.available_width(),
1911추가: );
1912추가: }
18691913 for warning in warnings
18701914 .iter()
18711915 .copied()
@@ -2383,6 +2427,57 @@ impl ArchiveApp {
23832427 cancel
23842428 }
23852429
2430추가: fn conflict_dialog(&mut self, ctx: &egui::Context) {
2431추가: let conflict = self.model.conflict.clone().unwrap();
2432추가: let question = (self.model.job_id().unwrap_or(0), conflict.challenge_id);
2433추가: if self.conflict_challenge != Some(question) {
2434추가: self.conflict_challenge = Some(question);
2435추가: self.conflict_apply = false;
2436추가: }
2437추가: let mut choice = None;
2438추가: let mut cancel = false;
2439추가: let modal = egui::Modal::new(egui::Id::unique("archive-conflict")).show(ctx, |ui| {
2440추가: ui.set_width((ctx.content_rect().width() - 64.0).min(460.0));
2441추가: ui.heading("같은 이름의 파일이 있습니다");
2442추가: theme::bounded_text(ui, &conflict.relative_name, ui.available_width());
2443추가: ui.add_space(theme::SPACE);
2444추가: egui::Grid::new("conflict-sizes")
2445추가: .spacing([24.0, 8.0])
2446추가: .show(ui, |ui| {
2447추가: ui.label("기존 파일");
2448추가: ui.label(present::bytes_text(conflict.existing_size));
2449추가: ui.end_row();
2450추가: ui.label("압축파일 안의 파일");
2451추가: ui.label(present::bytes_text(conflict.incoming_size));
2452추가: ui.end_row();
2453추가: });
2454추가: ui.add_space(theme::SPACE);
2455추가: ui.checkbox(&mut self.conflict_apply, "나머지 파일에도 같게 적용");
2456추가: ui.add_space(theme::SPACE);
2457추가: ui.horizontal_wrapped(|ui| {
2458추가: for (label, value) in [
2459추가: ("덮어쓰기", ConflictChoice::Overwrite),
2460추가: ("건너뛰기", ConflictChoice::Skip),
2461추가: ("이름 바꿔 저장", ConflictChoice::Rename),
2462추가: ] {
2463추가: if theme::action(ui, label, false, self.model.error.is_none()).clicked() {
2464추가: choice = Some(value);
2465추가: }
2466추가: }
2467추가: });
2468추가: ui.label("이름 바꿔 저장하면 같은 폴더에 번호를 붙입니다.");
2469추가: if let Some(error) = &self.model.error {
2470추가: Self::error_notice(ui, present::client_error_text(error));
2471추가: }
2472추가: cancel = theme::action(ui, "작업 취소", false, true).clicked();
2473추가: });
2474추가: if modal.should_close() || cancel {
2475추가: self.model.cancel();
2476추가: } else if let Some(choice) = choice {
2477추가: self.model.resolve_conflict(choice, self.conflict_apply);
2478추가: }
2479추가: }
2480추가:
23862481 fn password_dialog(&mut self, ctx: &egui::Context, new_challenge: bool) {
23872482 let (_, attempt, encrypt) = self.model.challenge.unwrap();
23882483 let mut submit = false;
수정experiments/rust-ui-memory-app/src/archive_ui.rs+106-2
@@ -70,9 +70,37 @@ impl Drop for Secret {
7070 self.0.fill(0);
7171 }
7272}
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추가: }
7393pub enum Command {
7494 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추가: },
76104 Cancel,
77105}
78106pub struct Request {
@@ -186,6 +214,8 @@ pub enum Event {
186214 attempt: u32,
187215 encrypt: bool,
188216 },
217추가: ConflictRequired(Conflict),
218추가: ConflictResolved(Resolution),
189219 Progress {
190220 stage: Stage,
191221 processed: u64,
@@ -247,6 +277,7 @@ struct Running {
247277 stderr_eof: bool,
248278 exit: Option<bool>,
249279 cancel_sequence: Option<u64>,
280추가: conflict_ids: BTreeSet<u64>,
250281}
251282#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
252283pub enum Close {
@@ -267,6 +298,8 @@ pub struct Model {
267298 pub selected: BTreeSet<u32>,
268299 pub terminal: Option<Terminal>,
269300 pub challenge: Option<(u64, u32, bool)>,
301추가: pub conflict: Option<Conflict>,
302추가: pub resolutions: Vec<Resolution>,
270303 pub progress: Option<(Stage, u64, Option<u64>, u64)>,
271304 pub outputs: Vec<(String, Disposition)>,
272305 pub cancel: Option<CancelStatus>,
@@ -375,6 +408,8 @@ impl Model {
375408 self.next_id = id;
376409 self.terminal = None;
377410 self.challenge = None;
411추가: self.conflict = None;
412추가: self.resolutions.clear();
378413 self.progress = None;
379414 self.outputs.clear();
380415 self.cancel = None;
@@ -396,6 +431,7 @@ impl Model {
396431 stderr_eof: false,
397432 exit: None,
398433 cancel_sequence: None,
434추가: conflict_ids: BTreeSet::new(),
399435 });
400436 started
401437 }
@@ -443,6 +479,29 @@ impl Model {
443479 .is_some()
444480 {
445481 self.challenge = None;
482추가: self.conflict = None;
483추가: self.input_error = None;
484추가: true
485추가: } else {
486추가: false
487추가: }
488추가: }
489추가: pub fn resolve_conflict(&mut self, choice: ConflictChoice, apply_to_remaining: bool) -> bool {
490추가: let Some(conflict) = &self.conflict else {
491추가: return false;
492추가: };
493추가: if self.cancellation_requested() || self.error.is_some() || self.close != Close::Open {
494추가: return false;
495추가: }
496추가: if self
497추가: .send(Command::ConflictReply {
498추가: challenge_id: conflict.challenge_id,
499추가: choice,
500추가: apply_to_remaining,
501추가: })
502추가: .is_some()
503추가: {
504추가: self.conflict = None;
446505 self.input_error = None;
447506 true
448507 } else {
@@ -483,6 +542,7 @@ impl Model {
483542 if let Some(seq) = self.send(Command::Cancel) {
484543 self.running.as_mut().unwrap().cancel_sequence = Some(seq);
485544 self.challenge = None;
545추가: self.conflict = None;
486546 self.input_error = None;
487547 }
488548 }
@@ -565,6 +625,7 @@ impl Model {
565625 self.selected.clear();
566626 }
567627 self.challenge = None;
628추가: self.conflict = None;
568629 self.input_error = None;
569630 if matches!(self.close, Close::Waiting | Close::Confirm) {
570631 self.close = Close::Review;
@@ -636,12 +697,51 @@ impl Model {
636697 attempt,
637698 encrypt,
638699 } => {
639삭제: if self.challenge.is_some() || challenge_id == 0 {
700추가: if self.challenge.is_some() || self.conflict.is_some() || challenge_id == 0
701추가: {
640702 self.error = Some("암호 요청이 유효하지 않습니다".into());
641703 } else {
642704 self.challenge = Some((challenge_id, attempt, encrypt));
643705 }
644706 }
707추가: Event::ConflictRequired(conflict) => {
708추가: let valid_entry = self
709추가: .entries
710추가: .iter()
711추가: .any(|entry| entry.id == conflict.entry_id && entry.kind == Kind::File);
712추가: if !matches!(run.start, Start::Extract { .. })
713추가: || !valid_entry
714추가: || conflict.challenge_id == 0
715추가: || self.challenge.is_some()
716추가: || self.conflict.is_some()
717추가: || run.conflict_ids.len() >= 100_000
718추가: || !valid_relative(&conflict.relative_name)
719추가: || conflict.relative_name.len() > 4096
720추가: || !run.conflict_ids.insert(conflict.challenge_id)
721추가: {
722추가: self.error = Some("파일 충돌 요청이 유효하지 않습니다".into());
723추가: } else if run.cancel_sequence.is_none() {
724추가: self.conflict = Some(conflict);
725추가: }
726추가: }
727추가: Event::ConflictResolved(resolution) => {
728추가: if !matches!(run.start, Start::Extract { .. })
729추가: || !self.entries.iter().any(|entry| {
730추가: entry.id == resolution.entry_id && entry.kind == Kind::File
731추가: })
732추가: || self.resolutions.len() >= 100_000
733추가: || self
734추가: .resolutions
735추가: .iter()
736추가: .any(|r| r.entry_id == resolution.entry_id)
737추가: || !valid_relative(&resolution.relative_name)
738추가: || resolution.relative_name.len() > 4096
739추가: {
740추가: self.error = Some("파일 충돌 결과가 유효하지 않습니다".into());
741추가: } else {
742추가: self.resolutions.push(resolution);
743추가: }
744추가: }
645745 Event::Progress {
646746 stage,
647747 processed,
@@ -671,6 +771,7 @@ impl Model {
671771 }
672772 Event::Terminal(t) => {
673773 self.challenge = None;
774추가: self.conflict = None;
674775 self.terminal = Some(t);
675776 }
676777 }
@@ -685,6 +786,9 @@ impl Model {
685786 if self.terminal.is_some() {
686787 return "작업 결과 수신 / 프로세스 종료 확인 중".into();
687788 }
789추가: if self.conflict.is_some() {
790추가: return "같은 이름의 파일을 처리할 방법을 선택하세요".into();
791추가: }
688792 if self.challenge.is_some() {
689793 return "암호를 입력하세요".into();
690794 }
수정tests/rust-app-ui/capture.rs+1-0
@@ -246,6 +246,7 @@ impl Connection for CaptureConnection {
246246 }
247247 }
248248 }
249추가: Command::ConflictReply { .. } => return Err("충돌 선택은 상황 명령으로 확인함".into()),
249250 Command::Password { .. } => self.finish(false),
250251 Command::Cancel => {
251252 self.event(Event::CancelAck {
추가tests/rust-app-ui/conflict_codec.rs+52-0
@@ -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추가: }
추가tests/rust-app-ui/conflicts.rs+291-0
@@ -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추가: }
수정tests/rust-app-ui/fake.rs+10-0
@@ -6,6 +6,7 @@ pub struct State {
66 pub requests: Vec<(u64, &'static str)>,
77 pub starts: Vec<Start>,
88 pub password_seen: bool,
9추가: pub conflict_replies: Vec<(u64, ConflictChoice, bool)>,
910 /// 마지막으로 받은 암호 원문. 화면에서 입력한 암호가 그대로 전달됐는지 확인할 때 씀.
1011 pub password: Vec<u8>,
1112 pub job: u64,
@@ -184,6 +185,15 @@ impl Connection for FakeConnection {
184185 s.complete_action();
185186 }
186187 }
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추가: }
187197 Command::Cancel => {
188198 s.requests.push((request.sequence, "cancel"));
189199 if !s.manual {
수정tests/rust-app-ui/regressions.rs+1-0
@@ -1,6 +1,7 @@
11#[cfg(feature = "ui")]
22mod dialogs;
33mod fake;
4추가: mod conflicts;
45#[cfg(feature = "ui")]
56mod native_dialogs;
67use fake::*;
수정tests/rust-app-ui/scenario_tests.rs+3-0
@@ -96,6 +96,9 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
9696 );
9797 assert!(app.model.input_error.is_none(), "{}", scenario.name);
9898 let expected = match scenario.name {
99추가: "conflict-choice" | "conflict-apply" => "나머지 파일에도 같게 적용",
100추가: "extract-skipped" => "모든 파일을 건너뛰었습니다",
101추가: "extract-renamed" => "이름 바꿔 저장: 읽어주세요 (1).txt",
99102 "empty" => "압축파일",
100103 "folder-empty" => "이 폴더는 비어 있습니다",
101104 "dialog-error" => "파일 선택 창을 열 수 없습니다",
수정tests/rust-app-ui/scenarios.rs+67-0
@@ -21,6 +21,10 @@ macro_rules! catalog {
2121}
2222
2323catalog! {
24추가: "conflict-choice" => "같은 이름 파일의 세 가지 처리 선택",
25추가: "conflict-apply" => "남은 충돌에 같은 선택 적용",
26추가: "extract-skipped" => "모든 파일을 건너뛴 정상 완료",
27추가: "extract-renamed" => "이름을 바꿔 저장한 완료 결과",
2428 "empty" => "빈 첫 화면",
2529 "archive" => "폴더와 파일이 있는 압축파일",
2630 "folder" => "사진 하위 폴더",
@@ -273,11 +277,70 @@ impl Scenario {
273277 "사진/풍경.jpg".into(),
274278 ])
275279 });
280추가: if matches!(self.name, "extract-skipped" | "extract-renamed") {
281추가: app.targets = Some(["읽어주세요.txt".into()].into_iter().collect());
282추가: app.directories.clear();
283추가: }
276284 assert!(app.start(request));
277285 {
278286 let mut state = state.borrow_mut();
279287 state.frame(Event::Accepted { encryption: true });
280288 match self.name {
289추가: "conflict-choice" | "conflict-apply" => {
290추가: state.frame(Event::ConflictRequired(Conflict {
291추가: challenge_id: 29,
292추가: entry_id: 1,
293추가: relative_name: "읽어주세요.txt".into(),
294추가: incoming_size: 1_287_952,
295추가: existing_size: 2048,
296추가: }));
297추가: }
298추가: "extract-skipped" | "extract-renamed" => {
299추가: let skip = self.name == "extract-skipped";
300추가: let name = if skip {
301추가: "읽어주세요.txt"
302추가: } else {
303추가: "읽어주세요 (1).txt"
304추가: };
305추가: state.frame(Event::ConflictResolved(Resolution {
306추가: entry_id: 1,
307추가: relative_name: name.into(),
308추가: choice: if skip {
309추가: ConflictChoice::Skip
310추가: } else {
311추가: ConflictChoice::Rename
312추가: },
313추가: }));
314추가: if !skip {
315추가: state.frame(Event::Output {
316추가: entry_id: Some(1),
317추가: relative_name: name.into(),
318추가: disposition: Disposition::Created,
319추가: });
320추가: }
321추가: state.frame(Event::Terminal(Terminal {
322추가: outcome: Outcome::Completed,
323추가: error: None,
324추가: publication: if skip {
325추가: Publication::None
326추가: } else {
327추가: Publication::Complete
328추가: },
329추가: created_count: u64::from(!skip),
330추가: retained_partial_count: 0,
331추가: durability: if skip {
332추가: Durability::NotApplicable
333추가: } else {
334추가: Durability::Synced
335추가: },
336추가: cleanup: Cleanup::Complete,
337추가: }));
338추가: state.queue.extend([
339추가: HostEvent::StdoutEof,
340추가: HostEvent::StderrEof,
341추가: HostEvent::Exited { success: true },
342추가: ]);
343추가: }
281344 "password" | "password-retry" | "password-create" => {
282345 state.frame(Event::PasswordRequired {
283346 challenge_id: 17,
@@ -380,6 +443,10 @@ impl Scenario {
380443 for _ in 0..64 {
381444 app.model.poll();
382445 }
446추가: if self.name == "conflict-apply" {
447추가: app.conflict_challenge = Some((app.model.job_id().unwrap(), 29));
448추가: app.conflict_apply = true;
449추가: }
383450 if self.name == "extract-unsynced" {
384451 app.details = true;
385452 }