Windows 작업자 경로와 ZIP 실패 안내를 수정함
- 작성자
- 호시노 히나타
- 작성 시각
- 커밋
1de33aeccb3b3208f9af53a0e052aca5e84d4a46- 부모
- 784e0a9
변경된 파일 8개
+215-20| @@ -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 | 추가: } |
| @@ -382,3 +382,16 @@ pub fn gzip_output_name(archive: &Path) -> String { | ||
| 382 | 382 | "압축 해제 파일".into() |
| 383 | 383 | } |
| 384 | 384 | } |
| 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 | 추가: } |
| @@ -150,7 +150,7 @@ fn list_to_ui(id: wire::ListId) -> ui::ListId { | ||
| 150 | 150 | fn start_to_wire(start: ui::Start) -> wire::Start { |
| 151 | 151 | let action = match start { |
| 152 | 152 | 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)), | |
| 154 | 154 | }, |
| 155 | 155 | ui::Start::Extract { |
| 156 | 156 | archive, |
| @@ -159,8 +159,10 @@ fn start_to_wire(start: ui::Start) -> wire::Start { | ||
| 159 | 159 | list_id, |
| 160 | 160 | gzip_output_name, |
| 161 | 161 | } => 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 | 추가: )), | |
| 164 | 166 | selection: match selection { |
| 165 | 167 | ui::Selection::All => wire::Selection::All, |
| 166 | 168 | ui::Selection::EntryIds(ids) => wire::Selection::EntryIds(ids), |
| @@ -177,11 +179,13 @@ fn start_to_wire(start: ui::Start) -> wire::Start { | ||
| 177 | 179 | sources: sources |
| 178 | 180 | .into_iter() |
| 179 | 181 | .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)), | |
| 181 | 183 | archive_name, |
| 182 | 184 | }) |
| 183 | 185 | .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 | 추가: )), | |
| 185 | 189 | method: match method { |
| 186 | 190 | ui::Method::Store => wire::Method::Store, |
| 187 | 191 | ui::Method::Deflate => wire::Method::Deflate, |
| @@ -162,7 +162,7 @@ impl ArchiveApp { | ||
| 162 | 162 | self.ui_error = Some("파일이나 폴더의 이름을 확인하세요".into()); |
| 163 | 163 | return; |
| 164 | 164 | } |
| 165 | 삭제: validated.push(path); | |
| 165 | 추가: validated.push(crate::archive_path::worker_path(&path)); | |
| 166 | 166 | } |
| 167 | 167 | let paths = validated; |
| 168 | 168 | if self.sources.is_empty() { |
| @@ -895,7 +895,11 @@ impl ArchiveApp { | ||
| 895 | 895 | if error.starts_with("암호는") { |
| 896 | 896 | error.as_str() |
| 897 | 897 | } else { |
| 898 | 삭제: "풀 위치와 선택한 항목을 확인하세요" | |
| 898 | 추가: if matches!(self.last_request, Some(Start::CreateZip { .. })) { | |
| 899 | 추가: "저장 위치와 추가한 항목을 확인하세요" | |
| 900 | 추가: } else { | |
| 901 | 추가: "풀 위치와 선택한 항목을 확인하세요" | |
| 902 | 추가: } | |
| 899 | 903 | }, |
| 900 | 904 | ); |
| 901 | 905 | } |
| @@ -1034,12 +1038,15 @@ impl ArchiveApp { | ||
| 1034 | 1038 | theme::bounded_text(ui, &path, ui.available_width()); |
| 1035 | 1039 | } else if let Some(code) = t.as_ref().and_then(|t| t.error) { |
| 1036 | 1040 | ui.label(if creating && code == ErrorCode::SourceChanged { |
| 1037 | 삭제: "묶을 파일이 바뀌었습니다. 파일을 확인한 뒤 다시 만드세요" | |
| 1041 | 추가: "묶을 파일이 바뀌었습니다. 파일을 확인한 뒤 다시 만드세요".to_owned() | |
| 1038 | 1042 | } else { |
| 1039 | 삭제: present::error_text(code) | |
| 1043 | 추가: present::operation_text(present::error_text(code), creating) | |
| 1040 | 1044 | }); |
| 1041 | 1045 | } 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 | 추가: )); | |
| 1043 | 1050 | } |
| 1044 | 1051 | for warning in warnings |
| 1045 | 1052 | .iter() |
| @@ -1048,7 +1055,10 @@ impl ArchiveApp { | ||
| 1048 | 1055 | { |
| 1049 | 1056 | ui.horizontal_wrapped(|ui| { |
| 1050 | 1057 | 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 | 추가: ); | |
| 1052 | 1062 | }); |
| 1053 | 1063 | } |
| 1054 | 1064 | if !success |
| @@ -1059,13 +1069,17 @@ impl ArchiveApp { | ||
| 1059 | 1069 | &self.model.outputs, |
| 1060 | 1070 | ) |
| 1061 | 1071 | { |
| 1062 | 삭제: ui.label("아무 파일도 풀지 않았습니다"); | |
| 1072 | 추가: ui.label(if creating { | |
| 1073 | 추가: "ZIP 파일을 만들지 않았습니다" | |
| 1074 | 추가: } else { | |
| 1075 | 추가: "아무 파일도 풀지 않았습니다" | |
| 1076 | 추가: }); | |
| 1063 | 1077 | } |
| 1064 | 1078 | if self.details { |
| 1065 | 1079 | theme::panel(theme::STRIPE).show(ui, |ui| { |
| 1066 | 1080 | if durability_in_details { |
| 1067 | 1081 | if let Some(warning) = durability_warning { |
| 1068 | 삭제: ui.label(warning); | |
| 1082 | 추가: ui.label(present::operation_text(warning, creating)); | |
| 1069 | 1083 | } |
| 1070 | 1084 | } |
| 1071 | 1085 | if let Some(t) = &t { |
| @@ -1441,23 +1455,27 @@ impl ArchiveApp { | ||
| 1441 | 1455 | } |
| 1442 | 1456 | } |
| 1443 | 1457 | Close::Review => { |
| 1458 | 추가: let creating = matches!(self.last_request, Some(Start::CreateZip { .. })); | |
| 1444 | 1459 | ui.heading("결과 확인 후 닫기"); |
| 1445 | 1460 | let wrote = self |
| 1446 | 1461 | .last_request |
| 1447 | 1462 | .as_ref() |
| 1448 | 1463 | .is_some_and(|request| !matches!(request, Start::List { .. })); |
| 1449 | 1464 | ui.label(if !wrote { |
| 1450 | 삭제: "프로그램을 닫을까요?" | |
| 1465 | 추가: "프로그램을 닫을까요?".to_owned() | |
| 1451 | 1466 | } else if self.model.confirmed { |
| 1452 | 삭제: "작업 결과를 확인한 뒤 닫으세요" | |
| 1467 | 추가: "작업 결과를 확인한 뒤 닫으세요".to_owned() | |
| 1453 | 1468 | } else { |
| 1454 | 삭제: present::UNCERTAIN | |
| 1469 | 추가: present::operation_text(present::UNCERTAIN, creating) | |
| 1455 | 1470 | }); |
| 1456 | 1471 | egui::ScrollArea::vertical() |
| 1457 | 1472 | .max_height(160.0) |
| 1458 | 1473 | .show(ui, |ui| { |
| 1459 | 1474 | 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 | 추가: ); | |
| 1461 | 1479 | } |
| 1462 | 1480 | if wrote { |
| 1463 | 1481 | for warning in present::warnings( |
| @@ -1467,7 +1485,10 @@ impl ArchiveApp { | ||
| 1467 | 1485 | &self.directories, |
| 1468 | 1486 | &self.model.outputs, |
| 1469 | 1487 | ) { |
| 1470 | 삭제: ui.colored_label(theme::WARNING, warning); | |
| 1488 | 추가: ui.colored_label( | |
| 1489 | 추가: theme::WARNING, | |
| 1490 | 추가: present::operation_text(warning, creating), | |
| 1491 | 추가: ); | |
| 1471 | 1492 | } |
| 1472 | 1493 | } |
| 1473 | 1494 | }); |
| @@ -19,3 +19,5 @@ pub mod archive_browser; | ||
| 19 | 19 | pub mod archive_dialog; |
| 20 | 20 | #[cfg(feature = "ui")] |
| 21 | 21 | pub mod archive_theme; |
| 22 | 추가: | |
| 23 | 추가: pub mod archive_path; |
| @@ -856,3 +856,5 @@ fn password_validation_and_retry_do_not_erase_transport_failure() { | ||
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | mod presentation; |
| 859 | 추가: | |
| 860 | 추가: mod windows_paths; |
| @@ -316,7 +316,11 @@ fn excluding_a_child_after_folder_selection_does_not_restore_it_during_extractio | ||
| 316 | 316 | app.model.selected = [0, 1, 2].into_iter().collect(); |
| 317 | 317 | app.browse_folder("docs"); |
| 318 | 318 | 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()])); | |
| 320 | 324 | app.set_dialogs(Box::new(dialogs)); |
| 321 | 325 | let ctx = egui::Context::default(); |
| 322 | 326 | policy_click(&ctx, &mut app, "excluded.txt"); |
| @@ -340,7 +344,11 @@ fn gzip_save_cancel_and_invalid_output_do_not_start_an_extraction() { | ||
| 340 | 344 | policy_click(&ctx, &mut app, "압축해제"); |
| 341 | 345 | assert_eq!(factory.state.borrow().starts.len(), 1); |
| 342 | 346 | 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")])); | |
| 344 | 352 | policy_click(&ctx, &mut app, "압축해제"); |
| 345 | 353 | assert_eq!(factory.state.borrow().starts.len(), 1); |
| 346 | 354 | assert!(!app.model.busy()); |
| @@ -465,3 +473,43 @@ fn empty_list_notices_remain_visible_in_the_archive_content_area() { | ||
| 465 | 473 | assert_eq!(factory.state.borrow().starts.len(), 1); |
| 466 | 474 | } |
| 467 | 475 | } |
| 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 | 추가: } |
| @@ -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 | 추가: } |