team-ljyzipelo

공개

Windows 작업자 경로와 ZIP 실패 안내를 수정함

작성자
호시노 히나타
작성 시각
커밋
1de33aeccb3b3208f9af53a0e052aca5e84d4a46
부모
784e0a9
이 시점의 파일 보기

변경된 파일 8개

+215-20
추가experiments/rust-ui-memory-app/src/archive_path.rs+30-0
@@ -0,0 +1,30 @@
1추가: use std::path::{Path, PathBuf};
2추가:
3추가: pub fn windows_path(text: &str) -> String {
4추가: let Some(path) = text.strip_prefix(r"\\?\") else {
5추가: return text.to_owned();
6추가: };
7추가: let bytes = path.as_bytes();
8추가: // 일반 드라이브의 의미가 바뀌지 않는 경로만 변환함.
9추가: if bytes.len() < 3
10추가: || !bytes[0].is_ascii_alphabetic()
11추가: || &bytes[1..3] != b":\\"
12추가: || (path.len() > 3
13추가: && path[3..].split('\\').any(|part| {
14추가: part.is_empty()
15추가: || worker_protocol::archive::valid_name(part, false).is_err()
16추가: || part.contains('/')
17추가: }))
18추가: {
19추가: return text.to_owned();
20추가: }
21추가: path.to_owned()
22추가: }
23추가:
24추가: pub fn worker_path(path: &Path) -> PathBuf {
25추가: #[cfg(windows)]
26추가: if let Some(text) = path.to_str() {
27추가: return PathBuf::from(windows_path(text));
28추가: }
29추가: path.to_path_buf()
30추가: }
수정experiments/rust-ui-memory-app/src/archive_present.rs+13-0
@@ -382,3 +382,16 @@ pub fn gzip_output_name(archive: &Path) -> String {
382382 "압축 해제 파일".into()
383383 }
384384}
385추가:
386추가: pub fn operation_text(text: &str, creating: bool) -> String {
387추가: if creating {
388추가: text.replace("풀 위치", "저장 위치")
389추가: .replace("선택한 항목", "추가한 항목")
390추가: .replace(
391추가: "일부 파일만 풀렸습니다. 풀린 파일은",
392추가: "ZIP 파일이 일부만 저장됐습니다. 저장된 파일은",
393추가: )
394추가: } else {
395추가: text.to_owned()
396추가: }
397추가: }
수정experiments/rust-ui-memory-app/src/archive_process.rs+9-5
@@ -150,7 +150,7 @@ fn list_to_ui(id: wire::ListId) -> ui::ListId {
150150fn start_to_wire(start: ui::Start) -> wire::Start {
151151 let action = match start {
152152 ui::Start::List { archive } => wire::Action::List {
153삭제: archive: wire::NativePath::from_path(&archive),
153추가: archive: wire::NativePath::from_path(&crate::archive_path::worker_path(&archive)),
154154 },
155155 ui::Start::Extract {
156156 archive,
@@ -159,8 +159,10 @@ fn start_to_wire(start: ui::Start) -> wire::Start {
159159 list_id,
160160 gzip_output_name,
161161 } => wire::Action::Extract {
162삭제: archive: wire::NativePath::from_path(&archive),
163삭제: destination: wire::NativePath::from_path(&destination),
162추가: archive: wire::NativePath::from_path(&crate::archive_path::worker_path(&archive)),
163추가: destination: wire::NativePath::from_path(&crate::archive_path::worker_path(
164추가: &destination,
165추가: )),
164166 selection: match selection {
165167 ui::Selection::All => wire::Selection::All,
166168 ui::Selection::EntryIds(ids) => wire::Selection::EntryIds(ids),
@@ -177,11 +179,13 @@ fn start_to_wire(start: ui::Start) -> wire::Start {
177179 sources: sources
178180 .into_iter()
179181 .map(|(path, archive_name)| wire::Source {
180삭제: path: wire::NativePath::from_path(&path),
182추가: path: wire::NativePath::from_path(&crate::archive_path::worker_path(&path)),
181183 archive_name,
182184 })
183185 .collect(),
184삭제: output_file: wire::NativePath::from_path(&output_file),
186추가: output_file: wire::NativePath::from_path(&crate::archive_path::worker_path(
187추가: &output_file,
188추가: )),
185189 method: match method {
186190 ui::Method::Store => wire::Method::Store,
187191 ui::Method::Deflate => wire::Method::Deflate,
수정experiments/rust-ui-memory-app/src/archive_screen.rs+34-13
@@ -162,7 +162,7 @@ impl ArchiveApp {
162162 self.ui_error = Some("파일이나 폴더의 이름을 확인하세요".into());
163163 return;
164164 }
165삭제: validated.push(path);
165추가: validated.push(crate::archive_path::worker_path(&path));
166166 }
167167 let paths = validated;
168168 if self.sources.is_empty() {
@@ -895,7 +895,11 @@ impl ArchiveApp {
895895 if error.starts_with("암호는") {
896896 error.as_str()
897897 } else {
898삭제: "풀 위치와 선택한 항목을 확인하세요"
898추가: if matches!(self.last_request, Some(Start::CreateZip { .. })) {
899추가: "저장 위치와 추가한 항목을 확인하세요"
900추가: } else {
901추가: "풀 위치와 선택한 항목을 확인하세요"
902추가: }
899903 },
900904 );
901905 }
@@ -1034,12 +1038,15 @@ impl ArchiveApp {
10341038 theme::bounded_text(ui, &path, ui.available_width());
10351039 } else if let Some(code) = t.as_ref().and_then(|t| t.error) {
10361040 ui.label(if creating && code == ErrorCode::SourceChanged {
1037삭제: "묶을 파일이 바뀌었습니다. 파일을 확인한 뒤 다시 만드세요"
1041추가: "묶을 파일이 바뀌었습니다. 파일을 확인한 뒤 다시 만드세요".to_owned()
10381042 } else {
1039삭제: present::error_text(code)
1043추가: present::operation_text(present::error_text(code), creating)
10401044 });
10411045 } else if let Some(error) = &self.model.error {
1042삭제: ui.label(present::client_error_text(error));
1046추가: ui.label(present::operation_text(
1047추가: present::client_error_text(error),
1048추가: creating,
1049추가: ));
10431050 }
10441051 for warning in warnings
10451052 .iter()
@@ -1048,7 +1055,10 @@ impl ArchiveApp {
10481055 {
10491056 ui.horizontal_wrapped(|ui| {
10501057 theme::icon(ui, Icon::Warning, 20.0);
1051삭제: ui.colored_label(theme::WARNING, warning);
1058추가: ui.colored_label(
1059추가: theme::WARNING,
1060추가: present::operation_text(warning, creating),
1061추가: );
10521062 });
10531063 }
10541064 if !success
@@ -1059,13 +1069,17 @@ impl ArchiveApp {
10591069 &self.model.outputs,
10601070 )
10611071 {
1062삭제: ui.label("아무 파일도 풀지 않았습니다");
1072추가: ui.label(if creating {
1073추가: "ZIP 파일을 만들지 않았습니다"
1074추가: } else {
1075추가: "아무 파일도 풀지 않았습니다"
1076추가: });
10631077 }
10641078 if self.details {
10651079 theme::panel(theme::STRIPE).show(ui, |ui| {
10661080 if durability_in_details {
10671081 if let Some(warning) = durability_warning {
1068삭제: ui.label(warning);
1082추가: ui.label(present::operation_text(warning, creating));
10691083 }
10701084 }
10711085 if let Some(t) = &t {
@@ -1441,23 +1455,27 @@ impl ArchiveApp {
14411455 }
14421456 }
14431457 Close::Review => {
1458추가: let creating = matches!(self.last_request, Some(Start::CreateZip { .. }));
14441459 ui.heading("결과 확인 후 닫기");
14451460 let wrote = self
14461461 .last_request
14471462 .as_ref()
14481463 .is_some_and(|request| !matches!(request, Start::List { .. }));
14491464 ui.label(if !wrote {
1450삭제: "프로그램을 닫을까요?"
1465추가: "프로그램을 닫을까요?".to_owned()
14511466 } else if self.model.confirmed {
1452삭제: "작업 결과를 확인한 뒤 닫으세요"
1467추가: "작업 결과를 확인한 뒤 닫으세요".to_owned()
14531468 } else {
1454삭제: present::UNCERTAIN
1469추가: present::operation_text(present::UNCERTAIN, creating)
14551470 });
14561471 egui::ScrollArea::vertical()
14571472 .max_height(160.0)
14581473 .show(ui, |ui| {
14591474 if let Some(code) = self.model.terminal.as_ref().and_then(|t| t.error) {
1460삭제: ui.colored_label(theme::ERROR, present::error_text(code));
1475추가: ui.colored_label(
1476추가: theme::ERROR,
1477추가: present::operation_text(present::error_text(code), creating),
1478추가: );
14611479 }
14621480 if wrote {
14631481 for warning in present::warnings(
@@ -1467,7 +1485,10 @@ impl ArchiveApp {
14671485 &self.directories,
14681486 &self.model.outputs,
14691487 ) {
1470삭제: ui.colored_label(theme::WARNING, warning);
1488추가: ui.colored_label(
1489추가: theme::WARNING,
1490추가: present::operation_text(warning, creating),
1491추가: );
14711492 }
14721493 }
14731494 });
수정experiments/rust-ui-memory-app/src/lib.rs+2-0
@@ -19,3 +19,5 @@ pub mod archive_browser;
1919pub mod archive_dialog;
2020#[cfg(feature = "ui")]
2121pub mod archive_theme;
22추가:
23추가: pub mod archive_path;
수정tests/rust-app-ui/regressions.rs+2-0
@@ -856,3 +856,5 @@ fn password_validation_and_retry_do_not_erase_transport_failure() {
856856}
857857
858858mod presentation;
859추가:
860추가: mod windows_paths;
수정tests/rust-app-ui/toolbar.rs+50-2
@@ -316,7 +316,11 @@ fn excluding_a_child_after_folder_selection_does_not_restore_it_during_extractio
316316 app.model.selected = [0, 1, 2].into_iter().collect();
317317 app.browse_folder("docs");
318318 let dialogs = TestDialogs::default();
319삭제: dialogs.0.borrow_mut().answers.push_back(Some(vec![scratch.0.clone()]));
319추가: dialogs
320추가: .0
321추가: .borrow_mut()
322추가: .answers
323추가: .push_back(Some(vec![scratch.0.clone()]));
320324 app.set_dialogs(Box::new(dialogs));
321325 let ctx = egui::Context::default();
322326 policy_click(&ctx, &mut app, "excluded.txt");
@@ -340,7 +344,11 @@ fn gzip_save_cancel_and_invalid_output_do_not_start_an_extraction() {
340344 policy_click(&ctx, &mut app, "압축해제");
341345 assert_eq!(factory.state.borrow().starts.len(), 1);
342346 assert_eq!(dialogs.0.borrow().requests[0].purpose, Purpose::SaveGzip);
343삭제: dialogs.0.borrow_mut().answers.push_back(Some(vec![scratch.0.join("invalid:name")]));
347추가: dialogs
348추가: .0
349추가: .borrow_mut()
350추가: .answers
351추가: .push_back(Some(vec![scratch.0.join("invalid:name")]));
344352 policy_click(&ctx, &mut app, "압축해제");
345353 assert_eq!(factory.state.borrow().starts.len(), 1);
346354 assert!(!app.model.busy());
@@ -465,3 +473,43 @@ fn empty_list_notices_remain_visible_in_the_archive_content_area() {
465473 assert_eq!(factory.state.borrow().starts.len(), 1);
466474 }
467475}
476추가:
477추가: #[test]
478추가: fn failed_zip_creation_shows_save_location_and_no_extraction_copy() {
479추가: let scratch = Folder::new();
480추가: let factory = FakeFactory::default();
481추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), None, false);
482추가: app.set_dialogs(Box::new(TestDialogs::default()));
483추가: let source = scratch.0.join("source.txt");
484추가: fs::write(&source, b"source").unwrap();
485추가: app.add_sources(vec![source]);
486추가: let ctx = egui::Context::default();
487추가: policy_click(&ctx, &mut app, "압축하기");
488추가: for _ in 0..30 {
489추가: policy_render(&ctx, &mut app, vec![]);
490추가: }
491추가: assert!(!app.model.busy());
492추가: app.model.outputs.clear();
493추가: app.model.terminal = Some(Terminal {
494추가: outcome: Outcome::Failed,
495추가: error: Some(ErrorCode::InvalidRequest),
496추가: publication: Publication::None,
497추가: created_count: 0,
498추가: retained_partial_count: 0,
499추가: durability: Durability::NotApplicable,
500추가: cleanup: Cleanup::Complete,
501추가: });
502추가: let shown = policy_render(&ctx, &mut app, vec![]);
503추가: for expected in [
504추가: "ZIP 파일을 만들지 못했습니다",
505추가: "저장 위치와 추가한 항목을 확인하세요",
506추가: "ZIP 파일을 만들지 않았습니다",
507추가: ] {
508추가: assert!(shown.iter().any(|(text, _)| text == expected), "{shown:?}");
509추가: }
510추가: assert!(
511추가: !shown
512추가: .iter()
513추가: .any(|(text, _)| text.contains("풀 위치") || text.contains("풀지 않았습니다"))
514추가: );
515추가: }
추가tests/rust-app-ui/windows_paths.rs+75-0
@@ -0,0 +1,75 @@
1추가: use zipelo_ui_memory_app::archive_path::windows_path;
2추가:
3추가: #[test]
4추가: fn ordinary_verbatim_drives_are_converted_without_changing_components() {
5추가: for (input, expected) in [
6추가: (r"\\?\C:\Users\사용자\one.txt", r"C:\Users\사용자\one.txt"),
7추가: (r"\\?\C:\", r"C:\"),
8추가: (r"D:\one.txt", r"D:\one.txt"),
9추가: ] {
10추가: assert_eq!(windows_path(input), expected);
11추가: }
12추가: }
13추가:
14추가: #[test]
15추가: fn unc_devices_and_ambiguous_components_remain_blocked() {
16추가: for input in [
17추가: r"\\?\UNC\server\share\one.txt",
18추가: r"\\server\share\one.txt",
19추가: r"\\.\C:\one.txt",
20추가: r"\\?\GLOBALROOT\Device\one",
21추가: r"\\?\C:\a\..\one",
22추가: r"\\?\C:\a\.\one",
23추가: r"\\?\C:\a\name.",
24추가: r"\\?\C:\a\name ",
25추가: r"\\?\C:\a\NUL",
26추가: r"\\?\C:\a\one:stream",
27추가: r"\\?\C:\a\\one",
28추가: r"\\?\C:\a/one",
29추가: r"\\?\C:one",
30추가: ] {
31추가: assert_eq!(windows_path(input), input);
32추가: }
33추가: }
34추가:
35추가: #[test]
36추가: fn creation_messages_use_save_vocabulary_and_preserve_warnings() {
37추가: use zipelo_ui_memory_app::archive_present::*;
38추가: for text in [
39추가: UNCERTAIN,
40추가: PARTIAL,
41추가: LEFTOVERS,
42추가: SYNC_FAILED,
43추가: CLEANUP_WARNING,
44추가: UNCONFIRMED_FINISH,
45추가: error_text(zipelo_ui_memory_app::archive_ui::ErrorCode::InvalidRequest),
46추가: ] {
47추가: assert_eq!(operation_text(text, false), text);
48추가: assert!(!operation_text(text, true).contains("풀 위치"));
49추가: }
50추가: assert!(operation_text(UNCERTAIN, true).contains("확인하지 못했습니다"));
51추가: }
52추가:
53추가: #[cfg(windows)]
54추가: #[test]
55추가: fn windows_native_contract_accepts_drives_and_still_rejects_unc() {
56추가: use std::path::Path;
57추가: use worker_protocol::protocol::NativePath;
58추가: use zipelo_ui_memory_app::archive_path::worker_path;
59추가: let ordinary = worker_path(Path::new(r"\\?\C:\Users\one.txt"));
60추가: assert_eq!(
61추가: NativePath::from_path(&ordinary).to_path().unwrap(),
62추가: Path::new(r"C:\Users\one.txt")
63추가: );
64추가: for text in [
65추가: r"\\?\UNC\server\share\one.txt",
66추가: r"\\server\share\one.txt",
67추가: r"\\?\C:\a\..\one",
68추가: ] {
69추가: assert!(
70추가: NativePath::from_path(&worker_path(Path::new(text)))
71추가: .to_path()
72추가: .is_err()
73추가: );
74추가: }
75추가: }