분할 7z 목록 연동과 조각 오류 안내를 추가한다
- 작성자
- 호시노 히나타
- 작성 시각
- 커밋
d480c490b12f4ca0ff148477ce9a2246d9b40d99- 부모
- dbed822
변경된 파일 12개
+650-21| @@ -168,3 +168,16 @@ Ubuntu 제거 안내는 패키지 관리자 터미널 출력입니다. 이전 | ||
| 168 | 168 | 실제 압축파일에서는 파일 하나를 선택하고 [미리보기]를 직접 눌렀을 때만 읽기를 시작한다. |
| 169 | 169 | 닫은 뒤 선택, 폴더 위치와 스크롤을 유지하고 실행 전 키보드 포커스로 돌아간다. |
| 170 | 170 | 시나리오의 텍스트와 이미지는 화면 점검용이며 디코더 검증은 실제 압축파일로 별도 수행한다. |
| 171 | 추가: | |
| 172 | 추가: ### 분할 7z | |
| 173 | 추가: | |
| 174 | 추가: 조각 오류와 제외 형식 안내는 주 창 안의 작업 결과 모달로 표시한다. 별도 결과 창 전환 없이 파일명과 재시도 방법을 확인할 수 있다. | |
| 175 | 추가: | |
| 176 | 추가: - split-archive: .7z.001 목록과 미리보기 비활성화. 분할 입력은 목록 보기와 풀기만 지원. | |
| 177 | 추가: - split-first-volume: .7z.002 등 선택 시 필요한 .001의 정확한 이름 안내. 자동으로 다른 파일을 열지 않음. | |
| 178 | 추가: - split-missing-volume: 확정된 중간 누락의 파일명과 같은 폴더에 모든 조각을 모은 뒤 .001을 다시 여는 방법 안내. | |
| 179 | 추가: - split-incomplete: 불완전하거나 손상된 묶음 안내. 마지막 누락 파일명을 추측하지 않음. | |
| 180 | 추가: - split-unsupported: 분할 ZIP, RAR과 분할 압축 만들기 미지원 안내. | |
| 181 | 추가: - split-source-changed: 목록 이후 조각 변경 시 다시 열기 안내. | |
| 182 | 추가: | |
| 183 | 추가: 운영체제 기본 열기 창에서 같은 폴더의 첫 조각 `.7z.001`을 선택한다. 분할 묶음은 최대 999개이며 목록 열람 성공은 전체 데이터 무결성 검증 완료를 뜻하지 않는다. 실제 분할 파일 처리는 작업자 구현 후 독립 도구 표본으로 확인한다. Windows와 Wayland에서 첫 조각 선택, 누락 이름, .001 재시도 안내와 닫기를 확인하며, 위 디자인 상황은 실제 파일 검증을 대신하지 않는다. |
| @@ -37,7 +37,9 @@ pub trait Dialogs { | ||
| 37 | 37 | |
| 38 | 38 | pub fn archive_filters() -> Vec<(&'static str, Vec<String>)> { |
| 39 | 39 | let mut extensions = Vec::new(); |
| 40 | 삭제: for extension in ["zip", "7z", "tar", "gz", "tgz", "tar.bz2", "tar.xz"] { | |
| 40 | 추가: for extension in [ | |
| 41 | 추가: "zip", "7z", "7z.001", "tar", "gz", "tgz", "tar.bz2", "tar.xz", | |
| 42 | 추가: ] { | |
| 41 | 43 | let mut variants = vec![String::new()]; |
| 42 | 44 | for character in extension.chars() { |
| 43 | 45 | let mut next = Vec::new(); |
| @@ -19,6 +19,9 @@ pub const FOLDER_ERROR: &str = "풀 위치 폴더를 만들 수 없습니다. | ||
| 19 | 19 | |
| 20 | 20 | pub fn error_text(code: ErrorCode) -> &'static str { |
| 21 | 21 | match code { |
| 22 | 추가: ErrorCode::MissingVolume => { | |
| 23 | 추가: "분할 압축파일의 조각이 없습니다. 모든 조각을 같은 폴더에 모은 뒤 .001을 다시 여세요" | |
| 24 | 추가: } | |
| 22 | 25 | ErrorCode::Integrity => "압축파일이 손상됐습니다", |
| 23 | 26 | ErrorCode::UnsupportedFormat => "지원하지 않는 압축 형식입니다", |
| 24 | 27 | ErrorCode::UnsupportedFeature => "아직 지원하지 않는 기능입니다", |
| @@ -425,3 +428,52 @@ pub fn operation_text(text: &str, creating: bool) -> String { | ||
| 425 | 428 | text.to_owned() |
| 426 | 429 | } |
| 427 | 430 | } |
| 431 | 추가: | |
| 432 | 추가: pub fn volume_problem_text(problem: &VolumeProblem) -> String { | |
| 433 | 추가: fn visible(c: char) -> String { | |
| 434 | 추가: if c.is_control() || matches!(c, '\u{202a}'..='\u{202e}' | '\u{2066}'..='\u{2069}') { | |
| 435 | 추가: c.escape_unicode().to_string() | |
| 436 | 추가: } else { | |
| 437 | 추가: c.to_string() | |
| 438 | 추가: } | |
| 439 | 추가: } | |
| 440 | 추가: let name = match &problem.volume { | |
| 441 | 추가: NativePath::Unix(bytes) => bytes | |
| 442 | 추가: .utf8_chunks() | |
| 443 | 추가: .map(|chunk| { | |
| 444 | 추가: let mut text = chunk.valid().chars().map(visible).collect::<String>(); | |
| 445 | 추가: for byte in chunk.invalid() { | |
| 446 | 추가: text.push_str(&format!("\\x{byte:02x}")); | |
| 447 | 추가: } | |
| 448 | 추가: text | |
| 449 | 추가: }) | |
| 450 | 추가: .collect::<String>(), | |
| 451 | 추가: NativePath::Windows(units) => char::decode_utf16(units.iter().copied()) | |
| 452 | 추가: .map(|c| { | |
| 453 | 추가: c.map(visible) | |
| 454 | 추가: .unwrap_or_else(|e| format!("\\u{{{:04x}}}", e.unpaired_surrogate())) | |
| 455 | 추가: }) | |
| 456 | 추가: .collect::<String>(), | |
| 457 | 추가: }; | |
| 458 | 추가: match problem.reason { | |
| 459 | 추가: VolumeProblemReason::FirstVolumeRequired => format!("첫 조각 {name}을 선택해 다시 여세요."), | |
| 460 | 추가: VolumeProblemReason::MissingVolume => { | |
| 461 | 추가: format!("{name} 조각이 없습니다. 모든 조각을 같은 폴더에 모은 뒤 .001을 다시 여세요.") | |
| 462 | 추가: } | |
| 463 | 추가: VolumeProblemReason::IncompleteSet => format!( | |
| 464 | 추가: "{name}의 분할 묶음이 불완전하거나 손상됐습니다. 모든 조각의 존재와 손상을 확인한 뒤 .001을 다시 여세요." | |
| 465 | 추가: ), | |
| 466 | 추가: } | |
| 467 | 추가: } | |
| 468 | 추가: | |
| 469 | 추가: pub const SPLIT_SUPPORT: &str = | |
| 470 | 추가: "분할 7z는 .7z.001부터 열 수 있습니다. 분할 ZIP과 RAR, 분할 압축 만들기는 지원하지 않습니다."; | |
| 471 | 추가: | |
| 472 | 추가: pub fn excluded_split(path: &Path) -> bool { | |
| 473 | 추가: let name = path | |
| 474 | 추가: .file_name() | |
| 475 | 추가: .unwrap_or_default() | |
| 476 | 추가: .to_string_lossy() | |
| 477 | 추가: .to_ascii_lowercase(); | |
| 478 | 추가: name.ends_with(".zip.001") || name.ends_with(".z01") || name.ends_with(".rar") | |
| 479 | 추가: } |
| @@ -135,6 +135,9 @@ fn list_to_wire(id: ui::ListId) -> wire::ListId { | ||
| 135 | 135 | catalog_version: id.catalog_version, |
| 136 | 136 | format: format_to_wire(id.format), |
| 137 | 137 | source_object: match id.source_object { |
| 138 | 추가: ui::SourceObject::SplitSevenZip { manifest_sha256 } => { | |
| 139 | 추가: wire::SourceObject::SplitSevenZip { manifest_sha256 } | |
| 140 | 추가: } | |
| 138 | 141 | ui::SourceObject::Unix { device, inode } => wire::SourceObject::Unix { device, inode }, |
| 139 | 142 | ui::SourceObject::Windows { volume, file_id } => wire::SourceObject::Windows { |
| 140 | 143 | volume_serial: volume, |
| @@ -150,6 +153,9 @@ fn list_to_ui(id: wire::ListId) -> ui::ListId { | ||
| 150 | 153 | catalog_version: id.catalog_version, |
| 151 | 154 | format: format_to_ui(id.format), |
| 152 | 155 | source_object: match id.source_object { |
| 156 | 추가: wire::SourceObject::SplitSevenZip { manifest_sha256 } => { | |
| 157 | 추가: ui::SourceObject::SplitSevenZip { manifest_sha256 } | |
| 158 | 추가: } | |
| 153 | 159 | wire::SourceObject::Unix { device, inode } => ui::SourceObject::Unix { device, inode }, |
| 154 | 160 | wire::SourceObject::Windows { |
| 155 | 161 | volume_serial, |
| @@ -229,6 +235,7 @@ fn start_to_wire(start: ui::Start) -> wire::Start { | ||
| 229 | 235 | } |
| 230 | 236 | fn error_to_ui(error: wire::ErrorCode) -> Option<ui::ErrorCode> { |
| 231 | 237 | Some(match error { |
| 238 | 추가: wire::ErrorCode::MissingVolume => ui::ErrorCode::MissingVolume, | |
| 232 | 239 | wire::ErrorCode::None => return None, |
| 233 | 240 | wire::ErrorCode::Integrity => ui::ErrorCode::Integrity, |
| 234 | 241 | wire::ErrorCode::UnsupportedFormat => ui::ErrorCode::UnsupportedFormat, |
| @@ -250,6 +257,14 @@ fn event_to_ui( | ||
| 250 | 257 | expected: Option<wire::ActionKind>, |
| 251 | 258 | ) -> Result<ui::Event, ()> { |
| 252 | 259 | Ok(match message { |
| 260 | 추가: wire::Message::VolumeProblem { reason, volume } | |
| 261 | 추가: if matches!( | |
| 262 | 추가: expected, | |
| 263 | 추가: Some(wire::ActionKind::List | wire::ActionKind::Extract) | |
| 264 | 추가: ) => | |
| 265 | 추가: { | |
| 266 | 추가: ui::Event::VolumeProblem(ui::VolumeProblem { reason, volume }) | |
| 267 | 추가: } | |
| 253 | 268 | wire::Message::Accepted { action, encryption } if expected == Some(action) => { |
| 254 | 269 | ui::Event::Accepted { encryption } |
| 255 | 270 | } |
| @@ -971,6 +971,13 @@ impl ArchiveApp { | ||
| 971 | 971 | idle && self.can_preview() && !self.preview_open, |
| 972 | 972 | false, |
| 973 | 973 | ) |
| 974 | 추가: .on_disabled_hover_text( | |
| 975 | 추가: if self.model.list_id.as_ref().is_some_and(ListId::is_split) { | |
| 976 | 추가: "분할 압축파일은 미리보기를 지원하지 않습니다" | |
| 977 | 추가: } else { | |
| 978 | 추가: "일반 파일 하나를 선택하세요" | |
| 979 | 추가: }, | |
| 980 | 추가: ) | |
| 974 | 981 | .clicked() |
| 975 | 982 | { |
| 976 | 983 | self.begin_preview(ui.ctx()); |
| @@ -1778,11 +1785,16 @@ impl ArchiveApp { | ||
| 1778 | 1785 | |
| 1779 | 1786 | fn limit_result_visible(&self) -> bool { |
| 1780 | 1787 | self.result_visible() |
| 1781 | 삭제: && self | |
| 1782 | 삭제: .model | |
| 1783 | 삭제: .terminal | |
| 1784 | 삭제: .as_ref() | |
| 1785 | 삭제: .is_some_and(|terminal| terminal.error == Some(ErrorCode::Limit)) | |
| 1788 | 추가: && (self.model.volume_problem.is_some() | |
| 1789 | 추가: || self.model.terminal.as_ref().is_some_and(|terminal| { | |
| 1790 | 추가: terminal.error == Some(ErrorCode::Limit) | |
| 1791 | 추가: || (terminal.error == Some(ErrorCode::UnsupportedFormat) | |
| 1792 | 추가: && self | |
| 1793 | 추가: .model | |
| 1794 | 추가: .archive | |
| 1795 | 추가: .as_ref() | |
| 1796 | 추가: .is_some_and(|p| present::excluded_split(p))) | |
| 1797 | 추가: })) | |
| 1786 | 1798 | } |
| 1787 | 1799 | |
| 1788 | 1800 | fn limit_result_dialog(&mut self, ctx: &egui::Context) { |
| @@ -2128,12 +2140,25 @@ impl ArchiveApp { | ||
| 2128 | 2140 | _ => format!("{} 폴더에 저장했습니다.", self.destination.display()), |
| 2129 | 2141 | }; |
| 2130 | 2142 | theme::bounded_text(ui, &path, ui.available_width()); |
| 2143 | 추가: } else if let Some(problem) = &self.model.volume_problem { | |
| 2144 | 추가: ui.add(egui::Label::new(present::volume_problem_text(problem)).wrap()); | |
| 2131 | 2145 | } else if let Some(code) = t.as_ref().and_then(|t| t.error) { |
| 2132 | 삭제: ui.label(if creating && code == ErrorCode::SourceChanged { | |
| 2133 | 삭제: "묶을 파일이 바뀌었습니다. 파일을 확인한 뒤 다시 만드세요".to_owned() | |
| 2134 | 삭제: } else { | |
| 2135 | 삭제: present::operation_text(present::error_text(code), creating) | |
| 2136 | 삭제: }); | |
| 2146 | 추가: ui.label( | |
| 2147 | 추가: if code == ErrorCode::UnsupportedFormat | |
| 2148 | 추가: && self | |
| 2149 | 추가: .model | |
| 2150 | 추가: .archive | |
| 2151 | 추가: .as_ref() | |
| 2152 | 추가: .is_some_and(|p| present::excluded_split(p)) | |
| 2153 | 추가: { | |
| 2154 | 추가: present::SPLIT_SUPPORT.to_owned() | |
| 2155 | 추가: } else if creating && code == ErrorCode::SourceChanged { | |
| 2156 | 추가: "묶을 파일이 바뀌었습니다. 파일을 확인한 뒤 다시 만드세요" | |
| 2157 | 추가: .to_owned() | |
| 2158 | 추가: } else { | |
| 2159 | 추가: present::operation_text(present::error_text(code), creating) | |
| 2160 | 추가: }, | |
| 2161 | 추가: ); | |
| 2137 | 2162 | } else if let Some(error) = &self.model.error { |
| 2138 | 2163 | ui.label(present::operation_text( |
| 2139 | 2164 | present::client_error_text(error), |
| @@ -12,6 +12,7 @@ pub enum Format { | ||
| 12 | 12 | pub enum SourceObject { |
| 13 | 13 | Unix { device: u64, inode: u64 }, |
| 14 | 14 | Windows { volume: u64, file_id: [u8; 16] }, |
| 15 | 추가: SplitSevenZip { manifest_sha256: [u8; 32] }, | |
| 15 | 16 | } |
| 16 | 17 | #[derive(Clone, Debug, Eq, PartialEq)] |
| 17 | 18 | pub struct ListId { |
| @@ -21,6 +22,26 @@ pub struct ListId { | ||
| 21 | 22 | pub archive_bytes: u64, |
| 22 | 23 | pub archive_sha256: [u8; 32], |
| 23 | 24 | } |
| 25 | 추가: impl ListId { | |
| 26 | 추가: pub fn valid(&self) -> bool { | |
| 27 | 추가: matches!( | |
| 28 | 추가: (self.catalog_version, self.format, &self.source_object), | |
| 29 | 추가: ( | |
| 30 | 추가: 1, | |
| 31 | 추가: _, | |
| 32 | 추가: SourceObject::Unix { .. } | SourceObject::Windows { .. } | |
| 33 | 추가: ) | (2, Format::SevenZip, SourceObject::SplitSevenZip { .. }) | |
| 34 | 추가: ) | |
| 35 | 추가: } | |
| 36 | 추가: pub fn is_split(&self) -> bool { | |
| 37 | 추가: matches!(self.source_object, SourceObject::SplitSevenZip { .. }) | |
| 38 | 추가: } | |
| 39 | 추가: } | |
| 40 | 추가: #[derive(Clone, Debug, Eq, PartialEq)] | |
| 41 | 추가: pub struct VolumeProblem { | |
| 42 | 추가: pub reason: VolumeProblemReason, | |
| 43 | 추가: pub volume: NativePath, | |
| 44 | 추가: } | |
| 24 | 45 | #[derive(Clone, Debug, Eq, PartialEq)] |
| 25 | 46 | pub enum Selection { |
| 26 | 47 | All, |
| @@ -159,6 +180,7 @@ pub enum Outcome { | ||
| 159 | 180 | } |
| 160 | 181 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
| 161 | 182 | pub enum ErrorCode { |
| 183 | 추가: MissingVolume, | |
| 162 | 184 | Integrity, |
| 163 | 185 | UnsupportedFormat, |
| 164 | 186 | UnsupportedFeature, |
| @@ -211,7 +233,8 @@ pub struct Terminal { | ||
| 211 | 233 | pub cleanup: Cleanup, |
| 212 | 234 | } |
| 213 | 235 | pub use worker_protocol::protocol::{ |
| 214 | 삭제: ActionKind, Limits, PreviewFormat, PreviewInfo, ResourceScope, ResourceUsage, | |
| 236 | 추가: ActionKind, Limits, NativePath, PreviewFormat, PreviewInfo, ResourceScope, ResourceUsage, | |
| 237 | 추가: VolumeProblemReason, | |
| 215 | 238 | }; |
| 216 | 239 | |
| 217 | 240 | pub struct Preview { |
| @@ -268,6 +291,7 @@ pub struct ResourceChallenge { | ||
| 268 | 291 | |
| 269 | 292 | #[derive(Clone, Debug)] |
| 270 | 293 | pub enum Event { |
| 294 | 추가: VolumeProblem(VolumeProblem), | |
| 271 | 295 | PreviewBegin(PreviewInfo), |
| 272 | 296 | PreviewChunk { |
| 273 | 297 | entry_id: u32, |
| @@ -342,6 +366,7 @@ impl Factory for Unavailable { | ||
| 342 | 366 | } |
| 343 | 367 | } |
| 344 | 368 | struct Running { |
| 369 | 추가: volume_problem: Option<VolumeProblem>, | |
| 345 | 370 | preview: Option<PreviewBuffer>, |
| 346 | 371 | preview_discarded: bool, |
| 347 | 372 | id: u64, |
| @@ -377,6 +402,7 @@ pub enum Close { | ||
| 377 | 402 | } |
| 378 | 403 | #[derive(Default)] |
| 379 | 404 | pub struct Model { |
| 405 | 추가: pub volume_problem: Option<VolumeProblem>, | |
| 380 | 406 | running: Option<Running>, |
| 381 | 407 | pub preview: Option<Preview>, |
| 382 | 408 | next_id: u64, |
| @@ -419,6 +445,7 @@ impl Model { | ||
| 419 | 445 | } |
| 420 | 446 | pub fn can_preview(&self) -> bool { |
| 421 | 447 | self.can_extract() |
| 448 | 추가: && self.list_id.as_ref().is_some_and(|id| !id.is_split()) | |
| 422 | 449 | && self.selected.len() == 1 |
| 423 | 450 | && self |
| 424 | 451 | .entries |
| @@ -579,6 +606,8 @@ impl Model { | ||
| 579 | 606 | list_id, |
| 580 | 607 | } => { |
| 581 | 608 | archive.is_absolute() |
| 609 | 추가: && list_id.valid() | |
| 610 | 추가: && !list_id.is_split() | |
| 582 | 611 | && self.archive.as_ref() == Some(archive) |
| 583 | 612 | && self.list_id.as_ref() == Some(list_id) |
| 584 | 613 | && self |
| @@ -632,6 +661,7 @@ impl Model { | ||
| 632 | 661 | }; |
| 633 | 662 | self.preview = None; |
| 634 | 663 | let estimated = self.estimate(&start); |
| 664 | 추가: self.volume_problem = None; | |
| 635 | 665 | let mut connection = match factory.connect(id) { |
| 636 | 666 | Ok(c) => c, |
| 637 | 667 | Err(e) => { |
| @@ -661,6 +691,7 @@ impl Model { | ||
| 661 | 691 | } |
| 662 | 692 | self.next_id = id; |
| 663 | 693 | self.terminal = None; |
| 694 | 추가: self.volume_problem = None; | |
| 664 | 695 | self.retry_start = None; |
| 665 | 696 | self.resource = None; |
| 666 | 697 | self.challenge = None; |
| @@ -673,6 +704,7 @@ impl Model { | ||
| 673 | 704 | self.error = send_error; |
| 674 | 705 | self.confirmed = false; |
| 675 | 706 | self.running = Some(Running { |
| 707 | 추가: volume_problem: None, | |
| 676 | 708 | preview: None, |
| 677 | 709 | preview_discarded: false, |
| 678 | 710 | id, |
| @@ -928,14 +960,18 @@ impl Model { | ||
| 928 | 960 | } |
| 929 | 961 | } |
| 930 | 962 | } |
| 931 | 삭제: if self | |
| 932 | 삭제: .terminal | |
| 933 | 삭제: .as_ref() | |
| 934 | 삭제: .is_some_and(|t| t.error == Some(ErrorCode::SourceChanged)) | |
| 935 | 삭제: { | |
| 963 | 추가: if self.terminal.as_ref().is_some_and(|t| { | |
| 964 | 추가: matches!( | |
| 965 | 추가: t.error, | |
| 966 | 추가: Some(ErrorCode::SourceChanged | ErrorCode::MissingVolume) | |
| 967 | 추가: ) | |
| 968 | 추가: }) { | |
| 936 | 969 | self.list_id = None; |
| 937 | 970 | self.selected.clear(); |
| 938 | 971 | } |
| 972 | 추가: if self.confirmed && run.cancel_sequence.is_none() { | |
| 973 | 추가: self.volume_problem = run.volume_problem.take(); | |
| 974 | 추가: } | |
| 939 | 975 | self.retry_start = if !matches!(run.start, Start::Preview { .. }) |
| 940 | 976 | && !run.expanded |
| 941 | 977 | && run.cancel_sequence.is_none() |
| @@ -991,6 +1027,19 @@ impl Model { | ||
| 991 | 1027 | return; |
| 992 | 1028 | } |
| 993 | 1029 | match event { |
| 1030 | 추가: Event::VolumeProblem(problem) => { | |
| 1031 | 추가: if run.cancel_sequence.is_some() { | |
| 1032 | 추가: return; | |
| 1033 | 추가: } | |
| 1034 | 추가: if run.volume_problem.is_some() | |
| 1035 | 추가: || !matches!(run.start, Start::List { .. } | Start::Extract { .. }) | |
| 1036 | 추가: || !problem.volume.is_basename() | |
| 1037 | 추가: { | |
| 1038 | 추가: self.error = Some("분할 조각 오류 응답이 유효하지 않습니다".into()); | |
| 1039 | 추가: } else { | |
| 1040 | 추가: run.volume_problem = Some(problem); | |
| 1041 | 추가: } | |
| 1042 | 추가: } | |
| 994 | 1043 | Event::PreviewBegin(info) => { |
| 995 | 1044 | if run.preview_discarded { |
| 996 | 1045 | return; |
| @@ -1080,7 +1129,7 @@ impl Model { | ||
| 1080 | 1129 | } => { |
| 1081 | 1130 | if !matches!(run.start, Start::List { .. }) |
| 1082 | 1131 | || run.list_end.is_some() |
| 1083 | 삭제: || list_id.catalog_version != 1 | |
| 1132 | 추가: || !list_id.valid() | |
| 1084 | 1133 | { |
| 1085 | 1134 | self.error = Some("목록 완료 응답이 유효하지 않습니다".into()); |
| 1086 | 1135 | } else { |
| @@ -1229,6 +1278,26 @@ impl Model { | ||
| 1229 | 1278 | } |
| 1230 | 1279 | } |
| 1231 | 1280 | Event::Terminal(t) => { |
| 1281 | 추가: if run.cancel_sequence.is_none() | |
| 1282 | 추가: && run.volume_problem.as_ref().is_some_and(|problem| { | |
| 1283 | 추가: t.outcome != Outcome::Failed | |
| 1284 | 추가: || t.error | |
| 1285 | 추가: != match problem.reason { | |
| 1286 | 추가: VolumeProblemReason::FirstVolumeRequired => { | |
| 1287 | 추가: Some(ErrorCode::InvalidRequest) | |
| 1288 | 추가: } | |
| 1289 | 추가: VolumeProblemReason::MissingVolume => { | |
| 1290 | 추가: Some(ErrorCode::MissingVolume) | |
| 1291 | 추가: } | |
| 1292 | 추가: VolumeProblemReason::IncompleteSet => { | |
| 1293 | 추가: Some(ErrorCode::Integrity) | |
| 1294 | 추가: } | |
| 1295 | 추가: } | |
| 1296 | 추가: }) | |
| 1297 | 추가: { | |
| 1298 | 추가: self.error = | |
| 1299 | 추가: Some("분할 조각 오류와 종료 상태가 일치하지 않습니다".into()); | |
| 1300 | 추가: } | |
| 1232 | 1301 | if matches!(run.start, Start::Preview { .. }) |
| 1233 | 1302 | && (t.publication != Publication::None |
| 1234 | 1303 | || t.created_count != 0 |
| @@ -1380,6 +1449,7 @@ pub fn terminal_lines(t: &Terminal) -> Vec<String> { | ||
| 1380 | 1449 | if let Some(error) = t.error { |
| 1381 | 1450 | lines.push( |
| 1382 | 1451 | match error { |
| 1452 | 추가: ErrorCode::MissingVolume => "분할 압축파일의 조각이 없습니다. 모든 조각을 같은 폴더에 모은 뒤 첫 조각을 다시 여세요", | |
| 1383 | 1453 | ErrorCode::Integrity => "압축파일이 손상됐습니다", |
| 1384 | 1454 | ErrorCode::UnsupportedFormat => "지원하지 않는 압축 형식입니다", |
| 1385 | 1455 | ErrorCode::UnsupportedFeature => "아직 지원하지 않는 기능입니다", |
| @@ -50,3 +50,60 @@ fn conflict_adapter_preserves_sizes_names_ids_and_choices() { | ||
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 추가: | |
| 54 | 추가: #[test] | |
| 55 | 추가: fn split_list_id_adapter_round_trip_preserves_manifest_and_logical_input() { | |
| 56 | 추가: let id = ui::ListId { | |
| 57 | 추가: catalog_version: 2, | |
| 58 | 추가: format: ui::Format::SevenZip, | |
| 59 | 추가: source_object: ui::SourceObject::SplitSevenZip { | |
| 60 | 추가: manifest_sha256: [0xa5; 32], | |
| 61 | 추가: }, | |
| 62 | 추가: archive_bytes: u64::MAX, | |
| 63 | 추가: archive_sha256: [0x5a; 32], | |
| 64 | 추가: }; | |
| 65 | 추가: let wire_id = list_to_wire(id.clone()); | |
| 66 | 추가: assert!(wire_id.valid()); | |
| 67 | 추가: assert_eq!(list_to_ui(wire_id), id); | |
| 68 | 추가: } | |
| 69 | 추가: #[test] | |
| 70 | 추가: fn volume_problem_adapter_preserves_native_filename_and_rejects_other_actions() { | |
| 71 | 추가: for volume in [ | |
| 72 | 추가: wire::NativePath::Unix(vec![0xff, 46, 55, 122]), | |
| 73 | 추가: wire::NativePath::Windows(vec![0xd800, 46, 55, 122]), | |
| 74 | 추가: ] { | |
| 75 | 추가: for action in [ | |
| 76 | 추가: Some(wire::ActionKind::List), | |
| 77 | 추가: Some(wire::ActionKind::Extract), | |
| 78 | 추가: Some(wire::ActionKind::Preview), | |
| 79 | 추가: Some(wire::ActionKind::CreateZip), | |
| 80 | 추가: None, | |
| 81 | 추가: ] { | |
| 82 | 추가: let event = event_to_ui( | |
| 83 | 추가: wire::Message::VolumeProblem { | |
| 84 | 추가: reason: wire::VolumeProblemReason::MissingVolume, | |
| 85 | 추가: volume: volume.clone(), | |
| 86 | 추가: }, | |
| 87 | 추가: action, | |
| 88 | 추가: ); | |
| 89 | 추가: if matches!( | |
| 90 | 추가: action, | |
| 91 | 추가: Some(wire::ActionKind::List | wire::ActionKind::Extract) | |
| 92 | 추가: ) { | |
| 93 | 추가: match event.unwrap() { | |
| 94 | 추가: ui::Event::VolumeProblem(problem) => { | |
| 95 | 추가: assert_eq!(problem.volume, volume); | |
| 96 | 추가: assert_eq!(problem.reason, wire::VolumeProblemReason::MissingVolume); | |
| 97 | 추가: } | |
| 98 | 추가: _ => panic!("조각 오류 변환 누락"), | |
| 99 | 추가: } | |
| 100 | 추가: } else { | |
| 101 | 추가: assert!(event.is_err()); | |
| 102 | 추가: } | |
| 103 | 추가: } | |
| 104 | 추가: } | |
| 105 | 추가: assert_eq!( | |
| 106 | 추가: error_to_ui(wire::ErrorCode::MissingVolume), | |
| 107 | 추가: Some(ui::ErrorCode::MissingVolume) | |
| 108 | 추가: ); | |
| 109 | 추가: } |
| @@ -10,9 +10,9 @@ fn archive_filter_contains_every_case_variant_and_all_files_option() { | ||
| 10 | 10 | assert_eq!(filters.len(), 2); |
| 11 | 11 | assert_eq!(filters[0].0, "압축파일"); |
| 12 | 12 | let expected = [ |
| 13 | 삭제: "zip", "ziP", "zIp", "zIP", "Zip", "ZiP", "ZIp", "ZIP", "7z", "7Z", "tar", "taR", "tAr", | |
| 14 | 삭제: "tAR", "Tar", "TaR", "TAr", "TAR", "gz", "gZ", "Gz", "GZ", "tgz", "tgZ", "tGz", "tGZ", | |
| 15 | 삭제: "Tgz", "TgZ", "TGz", "TGZ", | |
| 13 | 추가: "zip", "ziP", "zIp", "zIP", "Zip", "ZiP", "ZIp", "ZIP", "7z", "7Z", "7z.001", "7Z.001", | |
| 14 | 추가: "tar", "taR", "tAr", "tAR", "Tar", "TaR", "TAr", "TAR", "gz", "gZ", "Gz", "GZ", "tgz", | |
| 15 | 추가: "tgZ", "tGz", "tGZ", "Tgz", "TgZ", "TGz", "TGZ", | |
| 16 | 16 | ] |
| 17 | 17 | .into_iter() |
| 18 | 18 | .map(str::to_owned) |
| @@ -5,6 +5,7 @@ mod fake; | ||
| 5 | 5 | #[cfg(feature = "ui")] |
| 6 | 6 | mod native_dialogs; |
| 7 | 7 | mod preview; |
| 8 | 추가: mod split_volumes; | |
| 8 | 9 | use fake::*; |
| 9 | 10 | use std::path::PathBuf; |
| 10 | 11 | use zipelo_ui_memory_app::archive_ui::*; |
| @@ -95,7 +95,17 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() { | ||
| 95 | 95 | app.model.error |
| 96 | 96 | ); |
| 97 | 97 | assert!(app.model.input_error.is_none(), "{}", scenario.name); |
| 98 | 추가: if scenario.name == "split-archive" { | |
| 99 | 추가: assert!(app.model.list_id.as_ref().unwrap().is_split()); | |
| 100 | 추가: assert!(!app.model.can_preview()); | |
| 101 | 추가: } | |
| 98 | 102 | let expected = match scenario.name { |
| 103 | 추가: "split-archive" => "읽어주세요.txt", | |
| 104 | 추가: "split-first-volume" => "첫 조각 여행.7z.001을 선택해 다시 여세요.", | |
| 105 | 추가: "split-missing-volume" => "여행.7z.003 조각이 없습니다", | |
| 106 | 추가: "split-incomplete" => "분할 묶음이 불완전하거나 손상됐습니다", | |
| 107 | 추가: "split-unsupported" => "분할 ZIP과 RAR", | |
| 108 | 추가: "split-source-changed" => "원본 파일이 바뀌었습니다", | |
| 99 | 109 | "preview-implicit-folder" => "자료", |
| 100 | 110 | "preview-catalog-approval" | "preview-catalog-bytes-approval" => { |
| 101 | 111 | "큰 작업을 허용할까요?" |
| @@ -555,3 +565,41 @@ fn preview_image_respects_renderer_texture_limit() { | ||
| 555 | 565 | } |
| 556 | 566 | assert!(image_seen); |
| 557 | 567 | } |
| 568 | 추가: | |
| 569 | 추가: #[test] | |
| 570 | 추가: fn split_errors_use_main_modal_without_native_child() { | |
| 571 | 추가: for name in [ | |
| 572 | 추가: "split-first-volume", | |
| 573 | 추가: "split-missing-volume", | |
| 574 | 추가: "split-incomplete", | |
| 575 | 추가: "split-unsupported", | |
| 576 | 추가: ] { | |
| 577 | 추가: let scenario = scenarios::parse(name).unwrap(); | |
| 578 | 추가: let mut app = scenario.build(); | |
| 579 | 추가: let ctx = egui::Context::default(); | |
| 580 | 추가: ctx.set_embed_viewports(false); | |
| 581 | 추가: let mut labels = String::new(); | |
| 582 | 추가: for _ in 0..3 { | |
| 583 | 추가: let mut output = ctx.run_ui( | |
| 584 | 추가: egui::RawInput { | |
| 585 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 586 | 추가: egui::Pos2::ZERO, | |
| 587 | 추가: egui::vec2(1060.0, 720.0), | |
| 588 | 추가: )), | |
| 589 | 추가: ..Default::default() | |
| 590 | 추가: }, | |
| 591 | 추가: |ui| scenario.show(&mut app, ui), | |
| 592 | 추가: ); | |
| 593 | 추가: labels = text(&output.shapes); | |
| 594 | 추가: output.textures_delta.clear(); | |
| 595 | 추가: assert!( | |
| 596 | 추가: output | |
| 597 | 추가: .viewport_output | |
| 598 | 추가: .keys() | |
| 599 | 추가: .all(|id| *id == egui::ViewportId::ROOT), | |
| 600 | 추가: "{name}" | |
| 601 | 추가: ); | |
| 602 | 추가: } | |
| 603 | 추가: assert!(labels.contains("작업 결과"), "{name}: {labels}"); | |
| 604 | 추가: } | |
| 605 | 추가: } |
| @@ -21,6 +21,12 @@ macro_rules! catalog { | ||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | catalog! { |
| 24 | 추가: "split-archive" => "분할 7z 목록과 미리보기 비활성화", | |
| 25 | 추가: "split-first-volume" => "첫 조각의 정확한 파일명 안내", | |
| 26 | 추가: "split-missing-volume" => "누락 조각 파일명과 재시도 안내", | |
| 27 | 추가: "split-incomplete" => "누락 이름을 단정하지 않는 불완전 묶음 안내", | |
| 28 | 추가: "split-unsupported" => "분할 ZIP과 RAR 및 분할 생성 미지원 안내", | |
| 29 | 추가: "split-source-changed" => "목록 이후 분할 조각 변경 안내", | |
| 24 | 30 | "preview-catalog-bytes-approval" => "16 GiB를 넘는 전체 목록의 미리보기 승인", |
| 25 | 31 | "preview-catalog-approval" => "미리보기의 전체 목록 처리 예산 승인", |
| 26 | 32 | "preview-loading" => "미리보기 로딩과 취소", |
| @@ -262,6 +268,70 @@ impl Scenario { | ||
| 262 | 268 | archive_sha256: [7; 32], |
| 263 | 269 | }); |
| 264 | 270 | app.model.confirmed = true; |
| 271 | 추가: if self.name.starts_with("split-") { | |
| 272 | 추가: let archive = base.join(if self.name == "split-unsupported" { | |
| 273 | 추가: "여행.zip.001" | |
| 274 | 추가: } else { | |
| 275 | 추가: "여행.7z.001" | |
| 276 | 추가: }); | |
| 277 | 추가: app.model.archive = Some(archive.clone()); | |
| 278 | 추가: app.model.list_id = Some(ListId { | |
| 279 | 추가: catalog_version: 2, | |
| 280 | 추가: format: Format::SevenZip, | |
| 281 | 추가: source_object: SourceObject::SplitSevenZip { | |
| 282 | 추가: manifest_sha256: [9; 32], | |
| 283 | 추가: }, | |
| 284 | 추가: archive_bytes: 2_700_000, | |
| 285 | 추가: archive_sha256: [7; 32], | |
| 286 | 추가: }); | |
| 287 | 추가: if self.name == "split-archive" { | |
| 288 | 추가: app.model.selected.insert(1); | |
| 289 | 추가: return app; | |
| 290 | 추가: } | |
| 291 | 추가: app.start(Start::List { archive }); | |
| 292 | 추가: let mut state = state.borrow_mut(); | |
| 293 | 추가: state.frame(Event::Accepted { encryption: false }); | |
| 294 | 추가: let reason = match self.name { | |
| 295 | 추가: "split-first-volume" => Some(VolumeProblemReason::FirstVolumeRequired), | |
| 296 | 추가: "split-missing-volume" => Some(VolumeProblemReason::MissingVolume), | |
| 297 | 추가: "split-incomplete" => Some(VolumeProblemReason::IncompleteSet), | |
| 298 | 추가: _ => None, | |
| 299 | 추가: }; | |
| 300 | 추가: let error = match reason { | |
| 301 | 추가: Some(VolumeProblemReason::FirstVolumeRequired) => ErrorCode::InvalidRequest, | |
| 302 | 추가: Some(VolumeProblemReason::MissingVolume) => ErrorCode::MissingVolume, | |
| 303 | 추가: Some(VolumeProblemReason::IncompleteSet) => ErrorCode::Integrity, | |
| 304 | 추가: None if self.name == "split-source-changed" => ErrorCode::SourceChanged, | |
| 305 | 추가: None => ErrorCode::UnsupportedFormat, | |
| 306 | 추가: }; | |
| 307 | 추가: if let Some(reason) = reason { | |
| 308 | 추가: state.frame(Event::VolumeProblem(VolumeProblem { | |
| 309 | 추가: reason, | |
| 310 | 추가: volume: NativePath::Unix(if reason == VolumeProblemReason::MissingVolume { | |
| 311 | 추가: "여행.7z.003".as_bytes().to_vec() | |
| 312 | 추가: } else { | |
| 313 | 추가: "여행.7z.001".as_bytes().to_vec() | |
| 314 | 추가: }), | |
| 315 | 추가: })); | |
| 316 | 추가: } | |
| 317 | 추가: state.frame(Event::Terminal(Terminal { | |
| 318 | 추가: outcome: Outcome::Failed, | |
| 319 | 추가: error: Some(error), | |
| 320 | 추가: publication: Publication::None, | |
| 321 | 추가: created_count: 0, | |
| 322 | 추가: retained_partial_count: 0, | |
| 323 | 추가: durability: Durability::NotApplicable, | |
| 324 | 추가: cleanup: Cleanup::Complete, | |
| 325 | 추가: })); | |
| 326 | 추가: state.queue.push_back(HostEvent::StdoutEof); | |
| 327 | 추가: state.queue.push_back(HostEvent::StderrEof); | |
| 328 | 추가: state.queue.push_back(HostEvent::Exited { success: true }); | |
| 329 | 추가: drop(state); | |
| 330 | 추가: for _ in 0..32 { | |
| 331 | 추가: app.model.poll(); | |
| 332 | 추가: } | |
| 333 | 추가: return app; | |
| 334 | 추가: } | |
| 265 | 335 | if self.name.starts_with("preview-") { |
| 266 | 336 | app.model.selected = BTreeSet::from([1]); |
| 267 | 337 | if self.name == "preview-implicit-folder" { |
| @@ -0,0 +1,276 @@ | ||
| 1 | 추가: use super::*; | |
| 2 | 추가: | |
| 3 | 추가: fn split_id() -> ListId { | |
| 4 | 추가: ListId { | |
| 5 | 추가: catalog_version: 2, | |
| 6 | 추가: format: Format::SevenZip, | |
| 7 | 추가: source_object: SourceObject::SplitSevenZip { | |
| 8 | 추가: manifest_sha256: [19; 32], | |
| 9 | 추가: }, | |
| 10 | 추가: archive_bytes: 900, | |
| 11 | 추가: archive_sha256: [23; 32], | |
| 12 | 추가: } | |
| 13 | 추가: } | |
| 14 | 추가: fn setup() -> (Model, FakeFactory) { | |
| 15 | 추가: let mut model = Model::default(); | |
| 16 | 추가: let mut factory = FakeFactory::manual(); | |
| 17 | 추가: assert!(model.begin( | |
| 18 | 추가: Start::List { | |
| 19 | 추가: archive: path("자료.7z.001") | |
| 20 | 추가: }, | |
| 21 | 추가: &mut factory | |
| 22 | 추가: )); | |
| 23 | 추가: factory | |
| 24 | 추가: .state | |
| 25 | 추가: .borrow_mut() | |
| 26 | 추가: .frame(Event::Accepted { encryption: false }); | |
| 27 | 추가: (model, factory) | |
| 28 | 추가: } | |
| 29 | 추가: fn problem(reason: VolumeProblemReason) -> VolumeProblem { | |
| 30 | 추가: VolumeProblem { | |
| 31 | 추가: reason, | |
| 32 | 추가: volume: NativePath::Unix("자료.7z.003".as_bytes().to_vec()), | |
| 33 | 추가: } | |
| 34 | 추가: } | |
| 35 | 추가: fn terminal(factory: &FakeFactory, outcome: Outcome, error: Option<ErrorCode>) { | |
| 36 | 추가: factory.state.borrow_mut().frame(Event::Terminal(Terminal { | |
| 37 | 추가: outcome, | |
| 38 | 추가: error, | |
| 39 | 추가: publication: Publication::None, | |
| 40 | 추가: created_count: 0, | |
| 41 | 추가: retained_partial_count: 0, | |
| 42 | 추가: durability: Durability::NotApplicable, | |
| 43 | 추가: cleanup: Cleanup::Complete, | |
| 44 | 추가: })); | |
| 45 | 추가: } | |
| 46 | 추가: fn exited(factory: &FakeFactory) { | |
| 47 | 추가: let mut state = factory.state.borrow_mut(); | |
| 48 | 추가: state.queue.push_back(HostEvent::StdoutEof); | |
| 49 | 추가: state.queue.push_back(HostEvent::StderrEof); | |
| 50 | 추가: state.queue.push_back(HostEvent::Exited { success: true }); | |
| 51 | 추가: } | |
| 52 | 추가: #[test] | |
| 53 | 추가: fn split_list_id_is_preserved_for_extract_and_preview_cannot_start() { | |
| 54 | 추가: let (mut model, mut factory) = setup(); | |
| 55 | 추가: { | |
| 56 | 추가: let mut state = factory.state.borrow_mut(); | |
| 57 | 추가: state.frame(Event::Entry(Entry { | |
| 58 | 추가: id: 0, | |
| 59 | 추가: name: "small.txt".into(), | |
| 60 | 추가: kind: Kind::File, | |
| 61 | 추가: bytes: Some(7), | |
| 62 | 추가: packed: Some(9), | |
| 63 | 추가: encrypted: false, | |
| 64 | 추가: })); | |
| 65 | 추가: state.frame(Event::ListEnd { | |
| 66 | 추가: entry_count: 1, | |
| 67 | 추가: list_id: split_id(), | |
| 68 | 추가: }); | |
| 69 | 추가: } | |
| 70 | 추가: terminal(&factory, Outcome::Completed, None); | |
| 71 | 추가: exited(&factory); | |
| 72 | 추가: pump(&mut model); | |
| 73 | 추가: assert_eq!(model.list_id, Some(split_id())); | |
| 74 | 추가: assert!(model.can_extract()); | |
| 75 | 추가: model.selected.insert(0); | |
| 76 | 추가: assert!(!model.can_preview()); | |
| 77 | 추가: assert!(!model.begin_preview(&mut factory)); | |
| 78 | 추가: assert!(!model.begin( | |
| 79 | 추가: Start::Preview { | |
| 80 | 추가: archive: model.archive.clone().unwrap(), | |
| 81 | 추가: entry_id: 0, | |
| 82 | 추가: list_id: split_id() | |
| 83 | 추가: }, | |
| 84 | 추가: &mut factory | |
| 85 | 추가: )); | |
| 86 | 추가: assert!(model.extract(path("output"), true, None, &mut factory)); | |
| 87 | 추가: assert!( | |
| 88 | 추가: matches!(factory.state.borrow().starts.last(), Some(Start::Extract { list_id, .. }) if list_id == &split_id()) | |
| 89 | 추가: ); | |
| 90 | 추가: } | |
| 91 | 추가: #[test] | |
| 92 | 추가: fn split_list_id_rejects_invalid_version_format_and_source_combinations() { | |
| 93 | 추가: for id in [ | |
| 94 | 추가: ListId { | |
| 95 | 추가: catalog_version: 1, | |
| 96 | 추가: ..split_id() | |
| 97 | 추가: }, | |
| 98 | 추가: ListId { | |
| 99 | 추가: format: Format::Zip, | |
| 100 | 추가: ..split_id() | |
| 101 | 추가: }, | |
| 102 | 추가: ListId { | |
| 103 | 추가: source_object: SourceObject::Unix { | |
| 104 | 추가: device: 1, | |
| 105 | 추가: inode: 2, | |
| 106 | 추가: }, | |
| 107 | 추가: ..split_id() | |
| 108 | 추가: }, | |
| 109 | 추가: ] { | |
| 110 | 추가: let (mut model, factory) = setup(); | |
| 111 | 추가: factory.state.borrow_mut().frame(Event::ListEnd { | |
| 112 | 추가: entry_count: 0, | |
| 113 | 추가: list_id: id, | |
| 114 | 추가: }); | |
| 115 | 추가: terminal(&factory, Outcome::Completed, None); | |
| 116 | 추가: exited(&factory); | |
| 117 | 추가: pump(&mut model); | |
| 118 | 추가: assert!(model.error.is_some()); | |
| 119 | 추가: assert!(model.list_id.is_none()); | |
| 120 | 추가: } | |
| 121 | 추가: } | |
| 122 | 추가: #[test] | |
| 123 | 추가: fn volume_problem_waits_for_terminal_eofs_and_reap_and_clears_on_new_job() { | |
| 124 | 추가: let (mut model, mut factory) = setup(); | |
| 125 | 추가: factory | |
| 126 | 추가: .state | |
| 127 | 추가: .borrow_mut() | |
| 128 | 추가: .frame(Event::VolumeProblem(problem( | |
| 129 | 추가: VolumeProblemReason::MissingVolume, | |
| 130 | 추가: ))); | |
| 131 | 추가: terminal(&factory, Outcome::Failed, Some(ErrorCode::MissingVolume)); | |
| 132 | 추가: for _ in 0..32 { | |
| 133 | 추가: model.poll(); | |
| 134 | 추가: assert!(model.volume_problem.is_none()); | |
| 135 | 추가: } | |
| 136 | 추가: assert!(model.busy()); | |
| 137 | 추가: exited(&factory); | |
| 138 | 추가: pump(&mut model); | |
| 139 | 추가: assert!(model.confirmed); | |
| 140 | 추가: assert_eq!( | |
| 141 | 추가: model.volume_problem, | |
| 142 | 추가: Some(problem(VolumeProblemReason::MissingVolume)) | |
| 143 | 추가: ); | |
| 144 | 추가: assert!(model.begin( | |
| 145 | 추가: Start::List { | |
| 146 | 추가: archive: path("next.zip") | |
| 147 | 추가: }, | |
| 148 | 추가: &mut factory | |
| 149 | 추가: )); | |
| 150 | 추가: assert!(model.volume_problem.is_none()); | |
| 151 | 추가: } | |
| 152 | 추가: #[test] | |
| 153 | 추가: fn volume_problem_reason_requires_matching_failed_terminal() { | |
| 154 | 추가: for reason in [ | |
| 155 | 추가: VolumeProblemReason::FirstVolumeRequired, | |
| 156 | 추가: VolumeProblemReason::MissingVolume, | |
| 157 | 추가: VolumeProblemReason::IncompleteSet, | |
| 158 | 추가: ] { | |
| 159 | 추가: for valid in [true, false] { | |
| 160 | 추가: let (mut model, factory) = setup(); | |
| 161 | 추가: factory | |
| 162 | 추가: .state | |
| 163 | 추가: .borrow_mut() | |
| 164 | 추가: .frame(Event::VolumeProblem(problem(reason))); | |
| 165 | 추가: let error = match reason { | |
| 166 | 추가: VolumeProblemReason::FirstVolumeRequired => ErrorCode::InvalidRequest, | |
| 167 | 추가: VolumeProblemReason::MissingVolume => ErrorCode::MissingVolume, | |
| 168 | 추가: VolumeProblemReason::IncompleteSet => ErrorCode::Integrity, | |
| 169 | 추가: }; | |
| 170 | 추가: terminal( | |
| 171 | 추가: &factory, | |
| 172 | 추가: if valid { | |
| 173 | 추가: Outcome::Failed | |
| 174 | 추가: } else { | |
| 175 | 추가: Outcome::Completed | |
| 176 | 추가: }, | |
| 177 | 추가: Some(error), | |
| 178 | 추가: ); | |
| 179 | 추가: exited(&factory); | |
| 180 | 추가: pump(&mut model); | |
| 181 | 추가: assert_eq!(model.confirmed, valid); | |
| 182 | 추가: assert_eq!(model.volume_problem.is_some(), valid); | |
| 183 | 추가: } | |
| 184 | 추가: } | |
| 185 | 추가: let (mut model, factory) = setup(); | |
| 186 | 추가: factory | |
| 187 | 추가: .state | |
| 188 | 추가: .borrow_mut() | |
| 189 | 추가: .frame(Event::VolumeProblem(problem( | |
| 190 | 추가: VolumeProblemReason::MissingVolume, | |
| 191 | 추가: ))); | |
| 192 | 추가: terminal(&factory, Outcome::Failed, Some(ErrorCode::Integrity)); | |
| 193 | 추가: exited(&factory); | |
| 194 | 추가: pump(&mut model); | |
| 195 | 추가: assert!(!model.confirmed); | |
| 196 | 추가: assert!(model.volume_problem.is_none()); | |
| 197 | 추가: } | |
| 198 | 추가: #[test] | |
| 199 | 추가: fn duplicate_or_unsafe_volume_names_are_rejected() { | |
| 200 | 추가: for duplicate in [false, true] { | |
| 201 | 추가: let (mut model, factory) = setup(); | |
| 202 | 추가: let mut value = problem(VolumeProblemReason::MissingVolume); | |
| 203 | 추가: if !duplicate { | |
| 204 | 추가: value.volume = NativePath::Unix(b"../outside.7z.003".to_vec()); | |
| 205 | 추가: } | |
| 206 | 추가: factory | |
| 207 | 추가: .state | |
| 208 | 추가: .borrow_mut() | |
| 209 | 추가: .frame(Event::VolumeProblem(value.clone())); | |
| 210 | 추가: if duplicate { | |
| 211 | 추가: factory | |
| 212 | 추가: .state | |
| 213 | 추가: .borrow_mut() | |
| 214 | 추가: .frame(Event::VolumeProblem(value)); | |
| 215 | 추가: } | |
| 216 | 추가: terminal(&factory, Outcome::Failed, Some(ErrorCode::MissingVolume)); | |
| 217 | 추가: exited(&factory); | |
| 218 | 추가: pump(&mut model); | |
| 219 | 추가: assert!(!model.confirmed); | |
| 220 | 추가: assert!(model.volume_problem.is_none()); | |
| 221 | 추가: } | |
| 222 | 추가: } | |
| 223 | 추가: #[test] | |
| 224 | 추가: fn cancellation_discards_late_volume_problem() { | |
| 225 | 추가: let (mut model, factory) = setup(); | |
| 226 | 추가: for _ in 0..4 { | |
| 227 | 추가: model.poll(); | |
| 228 | 추가: } | |
| 229 | 추가: model.cancel(); | |
| 230 | 추가: factory | |
| 231 | 추가: .state | |
| 232 | 추가: .borrow_mut() | |
| 233 | 추가: .frame(Event::VolumeProblem(problem( | |
| 234 | 추가: VolumeProblemReason::MissingVolume, | |
| 235 | 추가: ))); | |
| 236 | 추가: factory.state.borrow_mut().frame(Event::CancelAck { | |
| 237 | 추가: request_sequence: 1, | |
| 238 | 추가: status: CancelStatus::Requested, | |
| 239 | 추가: }); | |
| 240 | 추가: terminal(&factory, Outcome::Cancelled, None); | |
| 241 | 추가: exited(&factory); | |
| 242 | 추가: pump(&mut model); | |
| 243 | 추가: assert!(model.confirmed, "{:?}", model.error); | |
| 244 | 추가: assert!(model.volume_problem.is_none()); | |
| 245 | 추가: } | |
| 246 | 추가: #[test] | |
| 247 | 추가: fn volume_filename_display_preserves_native_units_and_escapes_controls() { | |
| 248 | 추가: use zipelo_ui_memory_app::archive_present::volume_problem_text; | |
| 249 | 추가: let mut value = problem(VolumeProblemReason::MissingVolume); | |
| 250 | 추가: value.volume = NativePath::Unix(b"a\n\xff.7z.003".to_vec()); | |
| 251 | 추가: let text = volume_problem_text(&value); | |
| 252 | 추가: assert!(text.contains("a\\u{a}\\xff.7z.003"), "{text}"); | |
| 253 | 추가: assert!(!text.contains('\n')); | |
| 254 | 추가: value.volume = NativePath::Windows(vec![0xd800, 0x202e, 46, 55, 122, 46, 48, 48, 51]); | |
| 255 | 추가: let text = volume_problem_text(&value); | |
| 256 | 추가: assert!(text.contains("\\u{d800}\\u{202e}.7z.003"), "{text}"); | |
| 257 | 추가: } | |
| 258 | 추가: | |
| 259 | 추가: #[test] | |
| 260 | 추가: fn wrong_job_volume_problem_is_not_presented() { | |
| 261 | 추가: let (mut model, factory) = setup(); | |
| 262 | 추가: factory | |
| 263 | 추가: .state | |
| 264 | 추가: .borrow_mut() | |
| 265 | 추가: .frame(Event::VolumeProblem(problem( | |
| 266 | 추가: VolumeProblemReason::MissingVolume, | |
| 267 | 추가: ))); | |
| 268 | 추가: if let Some(HostEvent::Frame { job_id, .. }) = factory.state.borrow_mut().queue.back_mut() { | |
| 269 | 추가: *job_id += 1; | |
| 270 | 추가: } | |
| 271 | 추가: terminal(&factory, Outcome::Failed, Some(ErrorCode::MissingVolume)); | |
| 272 | 추가: exited(&factory); | |
| 273 | 추가: pump(&mut model); | |
| 274 | 추가: assert!(!model.confirmed); | |
| 275 | 추가: assert!(model.volume_problem.is_none()); | |
| 276 | 추가: } |