team-ljyzipelo

공개

ZIP 복구 결과와 경고 화면을 연결함

작성자
호시노 히나타
작성 시각
커밋
fec7fdd95034a49830fa6dfbeed5ae82e678068d
부모
902ecf5
이 시점의 파일 보기

변경된 파일 14개

+871-30
수정docs/ui-scenario-guide.md+18-0
@@ -192,3 +192,21 @@ Ubuntu 제거 안내는 패키지 관리자 터미널 출력입니다. 이전
192192- create-sevenzip-resource: 7z 생성의 큰 작업 허용 질문.
193193
1941947z를 선택하면 입력한 ZIP 암호와 실행 취소 기록을 지우며, ZIP으로 돌아와도 암호를 복원하지 않는다. 기본 저장 창은 .7z를 제안하며 암호가 필요하면 ZIP을 선택한다. 이 상황들은 가짜 작업자로 화면을 구성하므로 실제 7z 생성과 독립 도구 호환 시험을 대신하지 않는다.
195추가:
196추가: ### ZIP 복구
197추가:
198추가: 손상 오류에서 "복구본 저장 위치 선택"을 누르면 운영체제 기본 저장 창이 열립니다.
199추가: 원본을 수정하지 않고 새 ZIP을 만들며, 기존 파일은 덮어쓰지 않습니다.
200추가: 복구본 저장 완료와 일부 복구를 구분하고, 일부 복구본을 열어도 유실 경고를 유지합니다.
201추가: 검증된 항목도 손상 전 원본과 동일하다는 보증은 아닙니다.
202추가:
203추가: - recovery-progress: 항목 분석 중에는 전체 개수나 완료율을 추정하지 않습니다.
204추가: - recovery-complete: 검증과 저장, 작업자 종료를 확인한 복구본입니다.
205추가: - recovery-partial: 유실 항목을 구분하고 저장된 부분 복구본을 열 수 있습니다.
206추가: - recovery-unknown: 전체 목록을 알 수 없어 추가 유실 여부를 확인할 수 없습니다.
207추가: - recovery-impossible: 복구 가능한 항목과 생성된 복구본이 없습니다.
208추가: - recovery-cancelled: 취소 종료와 출력 없음 상태입니다.
209추가: - recovery-save-error: 분석이 끝났어도 저장 실패를 완료로 표시하지 않습니다.
210추가: - recovery-resource: 원본 제한은 유지하면서 압축률 예산 승인을 확인합니다.
211추가:
212추가: 예: `Zipelo --ui-scenario recovery-partial`. 상황 명령은 가짜 작업자만 사용합니다.
수정experiments/rust-ui-memory-app/src/archive_dialog.rs+28-17
@@ -7,6 +7,7 @@ pub enum Purpose {
77 Folder,
88 Destination,
99 Retry,
10추가: SaveRecoveryZip,
1011 SaveZip,
1112 SaveSevenZip,
1213 SaveGzip,
@@ -110,7 +111,7 @@ fn choose_portal(request: DialogRequest) -> Result<Option<Vec<PathBuf>>, String>
110111 use ashpd::desktop::file_chooser::{FileFilter, OpenFileRequest, SaveFileRequest};
111112 let filters = match request.purpose {
112113 Purpose::Open => archive_filters(),
113삭제: Purpose::SaveZip => vec![("ZIP 압축파일", vec!["zip".into()])],
114추가: Purpose::SaveZip | Purpose::SaveRecoveryZip => vec![("ZIP 압축파일", vec!["zip".into()])],
114115 Purpose::SaveSevenZip => vec![("7z 압축파일", vec!["7z".into()])],
115116 _ => Vec::new(),
116117 }
@@ -130,22 +131,26 @@ fn choose_portal(request: DialogRequest) -> Result<Option<Vec<PathBuf>>, String>
130131 .collect::<Vec<_>>();
131132 portal_response(pollster::block_on(async move {
132133 let selected = match request.purpose {
133삭제: Purpose::SaveZip | Purpose::SaveSevenZip | Purpose::SaveGzip | Purpose::RetryGzip => {
134삭제: SaveFileRequest::default()
135삭제: .title(if request.purpose == Purpose::SaveSevenZip {
136삭제: "7z 파일 저장"
137삭제: } else if request.purpose == Purpose::SaveZip {
138삭제: "ZIP 파일 저장"
139삭제: } else {
140삭제: "압축 해제 파일 저장"
141삭제: })
142삭제: .current_name(Some(request.file_name.as_str()))
143삭제: .filters(filters)
144삭제: .current_folder::<&PathBuf>(Some(&request.directory))?
145삭제: .send()
146삭제: .await?
147삭제: .response()?
148삭제: }
134추가: Purpose::SaveRecoveryZip
135추가: | Purpose::SaveZip
136추가: | Purpose::SaveSevenZip
137추가: | Purpose::SaveGzip
138추가: | Purpose::RetryGzip => SaveFileRequest::default()
139추가: .title(if request.purpose == Purpose::SaveRecoveryZip {
140추가: "복구본을 새 ZIP 파일로 저장"
141추가: } else if request.purpose == Purpose::SaveSevenZip {
142추가: "7z 파일 저장"
143추가: } else if request.purpose == Purpose::SaveZip {
144추가: "ZIP 파일 저장"
145추가: } else {
146추가: "압축 해제 파일 저장"
147추가: })
148추가: .current_name(Some(request.file_name.as_str()))
149추가: .filters(filters)
150추가: .current_folder::<&PathBuf>(Some(&request.directory))?
151추가: .send()
152추가: .await?
153추가: .response()?,
149154 purpose => OpenFileRequest::default()
150155 .title(match purpose {
151156 Purpose::Open => "압축파일 열기",
@@ -206,6 +211,12 @@ fn choose_native(request: DialogRequest) -> Result<Option<Vec<PathBuf>>, String>
206211 .add_filter("7z 압축파일", &["7z"])
207212 .save_file()
208213 .map(|path| vec![path]),
214추가: Purpose::SaveRecoveryZip => dialog
215추가: .set_title("복구본을 새 ZIP 파일로 저장")
216추가: .set_file_name(request.file_name)
217추가: .add_filter("ZIP 압축파일", &["zip"])
218추가: .save_file()
219추가: .map(|path| vec![path]),
209220 Purpose::SaveZip => dialog
210221 .set_title("ZIP 파일 저장")
211222 .set_file_name(request.file_name)
수정experiments/rust-ui-memory-app/src/archive_present.rs+2-0
@@ -19,6 +19,8 @@ pub const FOLDER_ERROR: &str = "풀 위치 폴더를 만들 수 없습니다.
1919
2020pub fn error_text(code: ErrorCode) -> &'static str {
2121 match code {
22추가: ErrorCode::RecoveryIncomplete => "일부 항목만 복구했습니다. 복구본과 경고를 확인하세요.",
23추가: ErrorCode::RecoveryImpossible => "복구 가능한 항목이 없습니다.",
2224 ErrorCode::MissingVolume => {
2325 "분할 압축파일의 조각이 없습니다. 모든 조각을 같은 폴더에 모은 뒤 .001을 다시 여세요"
2426 }
수정experiments/rust-ui-memory-app/src/archive_process.rs+17-0
@@ -201,6 +201,15 @@ fn start_to_wire(start: ui::Start) -> wire::Start {
201201 entry_id,
202202 list_id: list_to_wire(list_id),
203203 },
204추가: ui::Start::RecoverZip {
205추가: archive,
206추가: output_file,
207추가: } => wire::Action::RecoverZip {
208추가: archive: wire::NativePath::from_path(&crate::archive_path::worker_path(&archive)),
209추가: output_file: wire::NativePath::from_path(&crate::archive_path::worker_path(
210추가: &output_file,
211추가: )),
212추가: },
204213 ui::Start::CreateSevenZip {
205214 sources,
206215 output_file,
@@ -253,6 +262,8 @@ fn start_to_wire(start: ui::Start) -> wire::Start {
253262}
254263fn error_to_ui(error: wire::ErrorCode) -> Option<ui::ErrorCode> {
255264 Some(match error {
265추가: wire::ErrorCode::RecoveryIncomplete => ui::ErrorCode::RecoveryIncomplete,
266추가: wire::ErrorCode::RecoveryImpossible => ui::ErrorCode::RecoveryImpossible,
256267 wire::ErrorCode::MissingVolume => ui::ErrorCode::MissingVolume,
257268 wire::ErrorCode::None => return None,
258269 wire::ErrorCode::Integrity => ui::ErrorCode::Integrity,
@@ -275,6 +286,12 @@ fn event_to_ui(
275286 expected: Option<wire::ActionKind>,
276287) -> Result<ui::Event, ()> {
277288 Ok(match message {
289추가: wire::Message::RecoveryEntry(entry) if expected == Some(wire::ActionKind::RecoverZip) => {
290추가: ui::Event::RecoveryEntry(entry)
291추가: }
292추가: wire::Message::RecoveryEnd(end) if expected == Some(wire::ActionKind::RecoverZip) => {
293추가: ui::Event::RecoveryEnd(end)
294추가: }
278295 wire::Message::VolumeProblem { reason, volume }
279296 if matches!(
280297 expected,
수정experiments/rust-ui-memory-app/src/archive_screen.rs+192-4
@@ -243,6 +243,7 @@ pub struct ArchiveApp {
243243 list_focused: bool,
244244 marquee: Option<Marquee>,
245245 last_request: Option<Start>,
246추가: recovery_warning: Option<(PathBuf, String)>,
246247 targets: Option<BTreeSet<String>>,
247248 directories: BTreeSet<String>,
248249 dismissed: bool,
@@ -308,6 +309,7 @@ impl ArchiveApp {
308309 list_focused: false,
309310 marquee: None,
310311 last_request: None,
312추가: recovery_warning: None,
311313 targets: None,
312314 directories: BTreeSet::new(),
313315 dismissed: false,
@@ -450,6 +452,13 @@ impl ArchiveApp {
450452 if self.model.busy() {
451453 return;
452454 }
455추가: if self
456추가: .recovery_warning
457추가: .as_ref()
458추가: .is_some_and(|(path, _)| path != &archive)
459추가: {
460추가: self.recovery_warning = None;
461추가: }
453462 self.clear_password();
454463 self.destination = present::default_destination(&archive);
455464 self.automatic_destination = true;
@@ -468,6 +477,12 @@ impl ArchiveApp {
468477 if self.picker.is_some() {
469478 return false;
470479 }
480추가: if matches!(request, Start::RecoverZip { .. }) {
481추가: self.work = WorkWindow {
482추가: height: 480.0,
483추가: ..WorkWindow::default()
484추가: };
485추가: }
471486 self.last_request = Some(request.clone());
472487 self.dismissed = false;
473488 self.details = false;
@@ -682,7 +697,7 @@ impl ArchiveApp {
682697 };
683698 let directory = match purpose {
684699 Purpose::SaveZip | Purpose::SaveSevenZip => self.zip_folder.clone(),
685삭제: Purpose::Destination | Purpose::SaveGzip => self
700추가: Purpose::SaveRecoveryZip | Purpose::Destination | Purpose::SaveGzip => self
686701 .model
687702 .archive
688703 .as_ref()
@@ -700,7 +715,16 @@ impl ArchiveApp {
700715 let request = DialogRequest {
701716 purpose,
702717 directory,
703삭제: file_name: if matches!(purpose, Purpose::SaveGzip | Purpose::RetryGzip) {
718추가: file_name: if purpose == Purpose::SaveRecoveryZip {
719추가: let stem = self
720추가: .model
721추가: .archive
722추가: .as_ref()
723추가: .and_then(|p| p.file_stem())
724추가: .unwrap_or_default()
725추가: .to_string_lossy();
726추가: format!("{stem}-recovered.zip")
727추가: } else if matches!(purpose, Purpose::SaveGzip | Purpose::RetryGzip) {
704728 self.gzip_name.clone()
705729 } else {
706730 self.zip_name.clone()
@@ -734,6 +758,14 @@ impl ArchiveApp {
734758 Ok(Some(paths)) if !paths.is_empty() => {
735759 let path = paths[0].clone();
736760 match purpose {
761추가: Purpose::SaveRecoveryZip => {
762추가: if let Some(archive) = self.model.archive.clone() {
763추가: self.start(Start::RecoverZip {
764추가: archive,
765추가: output_file: path,
766추가: });
767추가: }
768추가: }
737769 Purpose::Open => {
738770 if std::fs::symlink_metadata(&path)
739771 .is_ok_and(|m| m.is_file() && !m.file_type().is_symlink())
@@ -812,7 +844,7 @@ impl ArchiveApp {
812844 if let Some(request) = self.last_request.clone() {
813845 match request {
814846 Start::List { archive } => self.open_path(archive),
815삭제: Start::Preview { .. } => {}
847추가: Start::Preview { .. } | Start::RecoverZip { .. } => {}
816848 Start::Extract {
817849 selection,
818850 gzip_output_name,
@@ -1066,6 +1098,9 @@ impl ArchiveApp {
10661098 .inner_margin(egui::Margin::ZERO),
10671099 )
10681100 .show(root, |ui| {
1101추가: if let Some((_, warning)) = &self.recovery_warning {
1102추가: ui.colored_label(theme::WARNING, warning);
1103추가: }
10691104 if self.model.archive.is_some() {
10701105 self.archive_list(ui);
10711106 } else {
@@ -1998,7 +2033,11 @@ impl ArchiveApp {
19982033 ) {
19992034 "저장 위치와 추가한 항목을 확인하세요"
20002035 } else {
2001삭제: "풀 위치와 선택한 항목을 확인하세요"
2036추가: if matches!(self.last_request, Some(Start::RecoverZip { .. })) {
2037추가: "원본과 다른 새 복구본 저장 위치를 선택하세요"
2038추가: } else {
2039추가: "풀 위치와 선택한 항목을 확인하세요"
2040추가: }
20022041 }
20032042 },
20042043 );
@@ -2006,6 +2045,20 @@ impl ArchiveApp {
20062045 }
20072046
20082047 fn progress(&mut self, ui: &mut egui::Ui) {
2048추가: if matches!(self.last_request, Some(Start::RecoverZip { .. })) {
2049추가: ui.strong("ZIP 복구 중");
2050추가: ui.label(if self.model.recovery_end.is_some() {
2051추가: "분석 완료 / 복구본 저장과 작업자 종료 확인 중"
2052추가: } else {
2053추가: "원본을 분석하고 있습니다. 전체 항목 수는 아직 알 수 없습니다."
2054추가: });
2055추가: ui.label(format!(
2056추가: "확인한 항목 {}개",
2057추가: self.model.recovery_entries.len()
2058추가: ));
2059추가: self.cancel_action(ui, false);
2060추가: return;
2061추가: }
20092062 if self.model.resource.is_some() {
20102063 ui.horizontal(|ui| {
20112064 ui.label("사용자 허용을 기다리고 있습니다");
@@ -2070,7 +2123,141 @@ impl ArchiveApp {
20702123 });
20712124 }
20722125
2126추가: fn recovery_result(&mut self, ui: &mut egui::Ui) {
2127추가: let t = self.model.terminal.as_ref();
2128추가: let summary = self.model.recovery_end.as_ref();
2129추가: let confirmed = self.model.confirmed && self.model.error.is_none();
2130추가: let saved = confirmed
2131추가: && t.is_some_and(|t| t.publication == Publication::Complete && t.created_count == 1)
2132추가: && summary.is_some_and(|s| s.verified_entries > 0);
2133추가: let partial = summary.is_some_and(|s| !s.complete());
2134추가: let title = if !confirmed {
2135추가: "복구 결과를 확정할 수 없음"
2136추가: } else if saved && partial {
2137추가: "일부 항목만 복구함"
2138추가: } else if saved && t.is_some_and(|t| t.outcome == Outcome::Completed) {
2139추가: "복구본 저장 완료"
2140추가: } else if t.is_some_and(|t| t.error == Some(ErrorCode::RecoveryImpossible)) {
2141추가: "복구 가능한 항목 없음"
2142추가: } else if t.is_some_and(|t| t.outcome == Outcome::Cancelled) {
2143추가: "복구를 취소했습니다"
2144추가: } else {
2145추가: "복구본 저장을 완료하지 못했습니다"
2146추가: };
2147추가: ui.heading(title);
2148추가: ui.label(
2149추가: "원본은 수정하지 않습니다. 검증 통과는 손상 전 내용과 동일하다는 보증이 아닙니다.",
2150추가: );
2151추가: let output = match &self.last_request {
2152추가: Some(Start::RecoverZip { output_file, .. }) => output_file.clone(),
2153추가: _ => return,
2154추가: };
2155추가: if saved || !self.model.outputs.is_empty() {
2156추가: theme::bounded_text(ui, &output.display().to_string(), ui.available_width());
2157추가: }
2158추가: if let Some(error) = &self.model.error {
2159추가: ui.colored_label(theme::WARNING, error);
2160추가: }
2161추가: if let Some(t) = t {
2162추가: if let Some(code) = t.error {
2163추가: ui.label(present::error_text(code));
2164추가: }
2165추가: for warning in present::publication_warnings(
2166추가: Some(t),
2167추가: self.model.confirmed,
2168추가: Some(&BTreeSet::from([output
2169추가: .file_name()
2170추가: .unwrap_or_default()
2171추가: .to_string_lossy()
2172추가: .into_owned()])),
2173추가: &BTreeSet::new(),
2174추가: &self.model.outputs,
2175추가: ) {
2176추가: ui.colored_label(theme::WARNING, warning);
2177추가: }
2178추가: if let Some(warning) = present::durability_warning(t.durability) {
2179추가: ui.colored_label(theme::WARNING, warning);
2180추가: }
2181추가: }
2182추가: let notice = summary.map(|s| {
2183추가: format!(
2184추가: "검증되어 포함됨 {}개 / 유실됨 {}개 / 무결성 미확인 {}개{}",
2185추가: s.verified_entries,
2186추가: s.lost_entries,
2187추가: s.unverified_entries,
2188추가: if s.unknown_loss {
2189추가: " / 전체 목록을 알 수 없어 추가 유실 여부를 확인할 수 없습니다"
2190추가: } else {
2191추가: ""
2192추가: }
2193추가: )
2194추가: });
2195추가: if let Some(notice) = &notice {
2196추가: ui.label(notice);
2197추가: }
2198추가: egui::ScrollArea::vertical()
2199추가: .id_salt("recovery-findings")
2200추가: .max_height(220.0)
2201추가: .show_rows(ui, 24.0, self.model.recovery_entries.len(), |ui, rows| {
2202추가: for entry in &self.model.recovery_entries[rows] {
2203추가: let status = match entry.status {
2204추가: RecoveryStatus::Verified => "검증되어 포함됨",
2205추가: RecoveryStatus::Lost => "유실됨",
2206추가: RecoveryStatus::Unverified => "무결성 미확인",
2207추가: };
2208추가: let reason = match entry.reason {
2209추가: RecoveryReason::None => "내용 검증 통과",
2210추가: RecoveryReason::HeaderRebuilt => "헤더 재구성",
2211추가: RecoveryReason::Truncated => "파일 절단",
2212추가: RecoveryReason::CrcMismatch => "CRC 불일치",
2213추가: RecoveryReason::DecodeFailure => "압축 데이터 손상",
2214추가: RecoveryReason::BoundaryUnknown => "항목 경계 불명",
2215추가: RecoveryReason::UnsupportedFeature => "지원하지 않는 기능",
2216추가: RecoveryReason::MetadataMissing => "메타정보 누락",
2217추가: };
2218추가: theme::bounded_text(
2219추가: ui,
2220추가: &format!(
2221추가: "{status} / {reason}: {}",
2222추가: entry.name.as_deref().unwrap_or("이름 확인 불가")
2223추가: ),
2224추가: ui.available_width(),
2225추가: );
2226추가: }
2227추가: });
2228추가: if saved && theme::action(ui, "복구본 열기", true, true).clicked() {
2229추가: self.recovery_warning = partial.then(|| (output.clone(), notice.unwrap_or_default()));
2230추가: self.open_path(output);
2231추가: }
2232추가: if self.model.can_retry_expanded()
2233추가: && theme::action(ui, "한도를 늘려 다시 시도", true, true).clicked()
2234추가: {
2235추가: self.model.retry_expanded(self.factory.as_mut());
2236추가: }
2237추가: }
2238추가:
20732239 fn result(&mut self, ui: &mut egui::Ui) {
2240추가: if matches!(self.last_request, Some(Start::RecoverZip { .. })) {
2241추가: self.recovery_result(ui);
2242추가: return;
2243추가: }
2244추가: if self.model.confirmed
2245추가: && self.model.error.is_none()
2246추가: && self
2247추가: .model
2248추가: .terminal
2249추가: .as_ref()
2250추가: .is_some_and(|t| t.error == Some(ErrorCode::Integrity))
2251추가: && matches!(
2252추가: self.last_request,
2253추가: Some(Start::List { .. } | Start::Extract { .. })
2254추가: )
2255추가: {
2256추가: ui.label("원본을 바꾸지 않고 새 ZIP 복구본을 만듭니다. 일부 항목은 복구되지 않을 수 있습니다.");
2257추가: if theme::action(ui, "복구본 저장 위치 선택", true, true).clicked() {
2258추가: self.open_picker(Purpose::SaveRecoveryZip);
2259추가: }
2260추가: }
20742261 let t = self.model.terminal.clone();
20752262 let listing = matches!(self.last_request, Some(Start::List { .. }));
20762263 let creating = matches!(
@@ -2873,6 +3060,7 @@ impl ArchiveApp {
28733060 ActionKind::Extract => "압축 해제",
28743061 ActionKind::CreateZip => "ZIP 만들기",
28753062 ActionKind::CreateSevenZip => "7z 만들기",
3063추가: ActionKind::RecoverZip => "ZIP 복구",
28763064 ActionKind::Preview => "파일 미리보기",
28773065 });
28783066 if question.scope.ratio {
수정experiments/rust-ui-memory-app/src/archive_ui.rs+134-6
@@ -69,6 +69,10 @@ pub enum Start {
6969 entry_id: u32,
7070 list_id: ListId,
7171 },
72추가: RecoverZip {
73추가: archive: PathBuf,
74추가: output_file: PathBuf,
75추가: },
7276 CreateSevenZip {
7377 sources: Vec<(PathBuf, String)>,
7478 output_file: PathBuf,
@@ -184,6 +188,8 @@ pub enum Outcome {
184188}
185189#[derive(Clone, Copy, Debug, Eq, PartialEq)]
186190pub enum ErrorCode {
191추가: RecoveryIncomplete,
192추가: RecoveryImpossible,
187193 MissingVolume,
188194 Integrity,
189195 UnsupportedFormat,
@@ -237,7 +243,8 @@ pub struct Terminal {
237243 pub cleanup: Cleanup,
238244}
239245pub use worker_protocol::protocol::{
240삭제: ActionKind, Limits, NativePath, PreviewFormat, PreviewInfo, ResourceScope, ResourceUsage,
246추가: ActionKind, Limits, NativePath, PreviewFormat, PreviewInfo, RecoveryEnd, RecoveryEntry,
247추가: RecoveryMode, RecoveryReason, RecoveryStatus, ResourceScope, ResourceUsage,
241248 VolumeProblemReason,
242249};
243250
@@ -295,6 +302,8 @@ pub struct ResourceChallenge {
295302
296303#[derive(Clone, Debug)]
297304pub enum Event {
305추가: RecoveryEntry(RecoveryEntry),
306추가: RecoveryEnd(RecoveryEnd),
298307 VolumeProblem(VolumeProblem),
299308 PreviewBegin(PreviewInfo),
300309 PreviewChunk {
@@ -370,6 +379,7 @@ impl Factory for Unavailable {
370379 }
371380}
372381struct Running {
382추가: recovery_metadata: usize,
373383 volume_problem: Option<VolumeProblem>,
374384 preview: Option<PreviewBuffer>,
375385 preview_discarded: bool,
@@ -406,6 +416,8 @@ pub enum Close {
406416}
407417#[derive(Default)]
408418pub struct Model {
419추가: pub recovery_entries: Vec<RecoveryEntry>,
420추가: pub recovery_end: Option<RecoveryEnd>,
409421 pub volume_problem: Option<VolumeProblem>,
410422 running: Option<Running>,
411423 pub preview: Option<Preview>,
@@ -539,7 +551,7 @@ impl Model {
539551 .iter()
540552 .try_fold(0u64, |sum, e| sum.checked_add(e.bytes?));
541553 }
542삭제: Start::List { .. } => {}
554추가: Start::List { .. } | Start::RecoverZip { .. } => {}
543555 }
544556 usage
545557 }
@@ -604,6 +616,10 @@ impl Model {
604616 .map(|e| e.id)
605617 .collect();
606618 let validation = match &start {
619추가: Start::RecoverZip {
620추가: archive,
621추가: output_file,
622추가: } => archive.is_absolute() && output_file.is_absolute() && archive != output_file,
607623 Start::List { archive } => archive.is_absolute(),
608624 Start::Preview {
609625 archive,
@@ -699,6 +715,8 @@ impl Model {
699715 self.selected.clear();
700716 }
701717 self.next_id = id;
718추가: self.recovery_entries.clear();
719추가: self.recovery_end = None;
702720 self.terminal = None;
703721 self.volume_problem = None;
704722 self.retry_start = None;
@@ -713,6 +731,7 @@ impl Model {
713731 self.error = send_error;
714732 self.confirmed = false;
715733 self.running = Some(Running {
734추가: recovery_metadata: 0,
716735 volume_problem: None,
717736 preview: None,
718737 preview_discarded: false,
@@ -1036,6 +1055,59 @@ impl Model {
10361055 return;
10371056 }
10381057 match event {
1058추가: Event::RecoveryEntry(entry) => {
1059추가: let budget = if run.granted.any() {
1060추가: 64 * 1024 * 1024
1061추가: } else {
1062추가: 8 * 1024 * 1024
1063추가: };
1064추가: let used = run.recovery_metadata;
1065추가: if !matches!(run.start, Start::RecoverZip { .. })
1066추가: || self.recovery_end.is_some()
1067추가: || !entry.valid()
1068추가: || entry.candidate_id as usize != self.recovery_entries.len()
1069추가: || entry.name.as_ref().is_some_and(|n| {
1070추가: n.len() > 4096 || !valid_relative(n.trim_end_matches('/'))
1071추가: })
1072추가: || self
1073추가: .recovery_entries
1074추가: .last()
1075추가: .is_some_and(|e| e.source_offset >= entry.source_offset)
1076추가: || self.recovery_entries.len()
1077추가: >= if run.granted.entries { 200_000 } else { 10_000 }
1078추가: || used + 128 + entry.name.as_ref().map_or(0, String::len) > budget
1079추가: {
1080추가: self.error = Some("복구 항목 응답이 유효하지 않습니다".into());
1081추가: } else {
1082추가: run.recovery_metadata +=
1083추가: 128 + entry.name.as_ref().map_or(0, String::len);
1084추가: self.recovery_entries.push(entry);
1085추가: }
1086추가: }
1087추가: Event::RecoveryEnd(summary) => {
1088추가: let count = |status| {
1089추가: self.recovery_entries
1090추가: .iter()
1091추가: .filter(|e| e.status == status)
1092추가: .count() as u32
1093추가: };
1094추가: if !matches!(run.start, Start::RecoverZip { .. })
1095추가: || self.recovery_end.is_some()
1096추가: || !summary.valid()
1097추가: || summary.source_bytes > 4 * 1024 * 1024 * 1024
1098추가: || self
1099추가: .recovery_entries
1100추가: .iter()
1101추가: .any(|e| e.source_offset >= summary.source_bytes)
1102추가: || summary.verified_entries != count(RecoveryStatus::Verified)
1103추가: || summary.lost_entries != count(RecoveryStatus::Lost)
1104추가: || summary.unverified_entries != count(RecoveryStatus::Unverified)
1105추가: {
1106추가: self.error = Some("복구 요약이 항목과 일치하지 않습니다".into());
1107추가: } else {
1108추가: self.recovery_end = Some(summary);
1109추가: }
1110추가: }
10391111 Event::VolumeProblem(problem) => {
10401112 if run.cancel_sequence.is_some() {
10411113 return;
@@ -1109,7 +1181,11 @@ impl Model {
11091181 }
11101182 }
11111183 Event::Accepted { encryption } => {
1112삭제: if matches!(run.start, Start::CreateSevenZip { .. }) && encryption {
1184추가: if matches!(
1185추가: run.start,
1186추가: Start::CreateSevenZip { .. } | Start::RecoverZip { .. }
1187추가: ) && encryption
1188추가: {
11131189 self.error = Some("7z 생성의 암호 응답이 유효하지 않습니다".into());
11141190 }
11151191 if run.accepted {
@@ -1156,8 +1232,10 @@ impl Model {
11561232 if run.cancel_sequence.is_some() {
11571233 return;
11581234 }
1159삭제: if matches!(run.start, Start::CreateSevenZip { .. })
1160삭제: || self.challenge.is_some()
1235추가: if matches!(
1236추가: run.start,
1237추가: Start::CreateSevenZip { .. } | Start::RecoverZip { .. }
1238추가: ) || self.challenge.is_some()
11611239 || self.resource.is_some()
11621240 || challenge_id <= run.last_challenge
11631241 || self.conflict.is_some()
@@ -1178,6 +1256,7 @@ impl Model {
11781256 Start::CreateZip { .. } => ActionKind::CreateZip,
11791257 Start::CreateSevenZip { .. } => ActionKind::CreateSevenZip,
11801258 Start::Preview { .. } => ActionKind::Preview,
1259추가: Start::RecoverZip { .. } => ActionKind::RecoverZip,
11811260 };
11821261 let hard = Limits {
11831262 input: u64::MAX,
@@ -1261,8 +1340,19 @@ impl Model {
12611340 Event::Output {
12621341 relative_name,
12631342 disposition,
1264삭제: ..
1343추가: entry_id,
12651344 } => {
1345추가: if let Start::RecoverZip { output_file, .. } = &run.start {
1346추가: if entry_id.is_some()
1347추가: || self.recovery_end.is_none()
1348추가: || !self.outputs.is_empty()
1349추가: || output_file.file_name().and_then(|n| n.to_str())
1350추가: != Some(relative_name.as_str())
1351추가: {
1352추가: self.error = Some("복구본 출력 응답이 유효하지 않습니다".into());
1353추가: return;
1354추가: }
1355추가: }
12661356 if matches!(run.start, Start::Preview { .. }) {
12671357 self.error = Some("미리보기 중 파일 출력이 보고됐습니다".into());
12681358 return;
@@ -1292,6 +1382,42 @@ impl Model {
12921382 }
12931383 }
12941384 Event::Terminal(t) => {
1385추가: if matches!(run.start, Start::RecoverZip { .. }) {
1386추가: let business = t.outcome == Outcome::Completed
1387추가: || matches!(
1388추가: t.error,
1389추가: Some(
1390추가: ErrorCode::RecoveryIncomplete
1391추가: | ErrorCode::RecoveryImpossible
1392추가: )
1393추가: );
1394추가: if business
1395추가: && !self.recovery_end.as_ref().is_some_and(|s| {
1396추가: if s.verified_entries == 0 {
1397추가: t.outcome == Outcome::Failed
1398추가: && t.error == Some(ErrorCode::RecoveryImpossible)
1399추가: && t.publication == Publication::None
1400추가: && t.created_count == 0
1401추가: && self.outputs.is_empty()
1402추가: } else {
1403추가: t.publication == Publication::Complete
1404추가: && t.created_count == 1
1405추가: && self.outputs.len() == 1
1406추가: && self.outputs[0].1 == Disposition::Created
1407추가: && if s.complete() {
1408추가: t.outcome == Outcome::Completed && t.error.is_none()
1409추가: } else {
1410추가: t.outcome == Outcome::Failed
1411추가: && t.error
1412추가: == Some(ErrorCode::RecoveryIncomplete)
1413추가: }
1414추가: }
1415추가: })
1416추가: {
1417추가: self.error =
1418추가: Some("복구 결과와 저장 상태가 일치하지 않습니다".into());
1419추가: }
1420추가: }
12951421 if run.cancel_sequence.is_none()
12961422 && run.volume_problem.as_ref().is_some_and(|problem| {
12971423 t.outcome != Outcome::Failed
@@ -1463,6 +1589,8 @@ pub fn terminal_lines(t: &Terminal) -> Vec<String> {
14631589 if let Some(error) = t.error {
14641590 lines.push(
14651591 match error {
1592추가: ErrorCode::RecoveryIncomplete => "일부 항목만 복구했습니다",
1593추가: ErrorCode::RecoveryImpossible => "복구 가능한 항목이 없습니다",
14661594 ErrorCode::MissingVolume => "분할 압축파일의 조각이 없습니다. 모든 조각을 같은 폴더에 모은 뒤 첫 조각을 다시 여세요",
14671595 ErrorCode::Integrity => "압축파일이 손상됐습니다",
14681596 ErrorCode::UnsupportedFormat => "지원하지 않는 압축 형식입니다",
수정tests/rust-app-real-worker/flows.rs+46-2
@@ -11,8 +11,7 @@ static NEXT: AtomicU64 = AtomicU64::new(0);
1111struct Scratch(PathBuf);
1212impl Scratch {
1313 fn new() -> Self {
14삭제: let root =
15삭제: Path::new(env!("CARGO_MANIFEST_DIR")).join("../../tests/rust-app-real-worker/runs");
14추가: let root = std::env::temp_dir().join("app-real-worker");
1615 fs::create_dir_all(&root).unwrap();
1716 let path = root.join(format!(
1817 "{}-{}",
@@ -699,3 +698,48 @@ fn cancel_racing_exit_without_terminal_remains_unconfirmed() {
699698mod guarded_flows;
700699
701700mod preview_catalog;
701추가:
702추가: #[test]
703추가: fn recovery_adapter_confirms_complete_partial_and_impossible_without_changing_source() {
704추가: use sha2::{Digest, Sha256};
705추가: let fixtures = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../tests/zip-recovery-fixtures");
706추가: for (name, expected, count) in [
707추가: ("broken-local-header.zip", None, 1),
708추가: (
709추가: "missing-directory.zip",
710추가: Some(ErrorCode::RecoveryIncomplete),
711추가: 1,
712추가: ),
713추가: ("body-corrupt.zip", Some(ErrorCode::RecoveryIncomplete), 1),
714추가: ("unrecoverable.zip", Some(ErrorCode::RecoveryImpossible), 0),
715추가: ] {
716추가: let scratch = Scratch::new();
717추가: let source = scratch.path("source.zip");
718추가: fs::copy(fixtures.join(name), &source).unwrap();
719추가: let before = Sha256::digest(fs::read(&source).unwrap());
720추가: let output = scratch.path("recovered.zip");
721추가: let mut model = Model::default();
722추가: let (mut factory, observed) = observed_factory();
723추가: assert!(model.begin(
724추가: Start::RecoverZip {
725추가: archive: source.clone(),
726추가: output_file: output.clone()
727추가: },
728추가: &mut factory
729추가: ));
730추가: wait(&mut model);
731추가: assert!(model.confirmed, "{name}: {:?}", model.error);
732추가: let terminal = model.terminal.as_ref().unwrap();
733추가: assert_eq!(terminal.error, expected, "{name}");
734추가: assert_eq!(terminal.created_count, count);
735추가: assert_eq!(output.exists(), count == 1);
736추가: assert_eq!(Sha256::digest(fs::read(source).unwrap()), before);
737추가: assert_reaped(&observed);
738추가: if count == 1 {
739추가: assert!(model.begin(Start::List { archive: output }, &mut factory));
740추가: wait(&mut model);
741추가: completed(&model);
742추가: assert!(model.list_id.is_some());
743추가: }
744추가: }
745추가: }
수정tests/rust-app-ui/capture.rs+3-0
@@ -236,6 +236,9 @@ impl Connection for CaptureConnection {
236236 durability: Durability::NotApplicable,
237237 cleanup: Cleanup::Complete,
238238 }),
239추가: Start::RecoverZip { .. } => {
240추가: return Err("복구 상황은 --ui-scenario로 확인함".into());
241추가: }
239242 Start::CreateSevenZip { output_file, .. } => {
240243 self.create_name =
241244 Some(output_file.file_name().unwrap().to_string_lossy().into());
수정tests/rust-app-ui/dialogs.rs+4-1
@@ -23,7 +23,10 @@ impl Dialogs for TestDialogs {
2323 if let Some(answer) = state.answers.pop_front() {
2424 return Ok(answer);
2525 }
26삭제: if matches!(request.purpose, Purpose::SaveZip | Purpose::SaveSevenZip) && !state.cancel_save
26추가: if matches!(
27추가: request.purpose,
28추가: Purpose::SaveZip | Purpose::SaveSevenZip | Purpose::SaveRecoveryZip
29추가: ) && !state.cancel_save
2730 {
2831 let name = state.save_name.take().unwrap_or(request.file_name);
2932 return Ok(Some(vec![request.directory.join(name)]));
수정tests/rust-app-ui/presentation.rs+104-0
@@ -503,6 +503,110 @@ mod widgets {
503503 );
504504 }
505505
506추가: #[test]
507추가: fn recovery_save_uses_native_dialog_and_partial_copy_keeps_warning_when_opened() {
508추가: let scratch = Folder::new();
509추가: let factory = FakeFactory::manual();
510추가: let archive = scratch.0.join("손상.zip");
511추가: let output = scratch.0.join("복구본.zip");
512추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), Some(archive.clone()), false);
513추가: {
514추가: let mut state = factory.state.borrow_mut();
515추가: state.frame(Event::Accepted { encryption: false });
516추가: state.frame(Event::Terminal(Terminal {
517추가: outcome: Outcome::Failed,
518추가: error: Some(ErrorCode::Integrity),
519추가: publication: Publication::None,
520추가: created_count: 0,
521추가: retained_partial_count: 0,
522추가: durability: Durability::NotApplicable,
523추가: cleanup: Cleanup::Complete,
524추가: }));
525추가: state.queue.extend([
526추가: HostEvent::StdoutEof,
527추가: HostEvent::StderrEof,
528추가: HostEvent::Exited { success: true },
529추가: ]);
530추가: }
531추가: pump(&mut app.model);
532추가: let dialogs = TestDialogs::default();
533추가: dialogs
534추가: .0
535추가: .borrow_mut()
536추가: .answers
537추가: .push_back(Some(vec![output.clone()]));
538추가: app.set_dialogs(Box::new(dialogs.clone()));
539추가: let ctx = egui::Context::default();
540추가: click(&ctx, &mut app, "복구본 저장 위치 선택");
541추가: assert_eq!(
542추가: dialogs.0.borrow().requests[0].purpose,
543추가: Purpose::SaveRecoveryZip
544추가: );
545추가: assert_eq!(
546추가: dialogs.0.borrow().requests[0].file_name,
547추가: "손상-recovered.zip"
548추가: );
549추가: assert!(
550추가: matches!(factory.state.borrow().starts.last(), Some(Start::RecoverZip { archive: actual, output_file }) if actual == &archive && output_file == &output)
551추가: );
552추가: {
553추가: let mut state = factory.state.borrow_mut();
554추가: state.frame(Event::Accepted { encryption: false });
555추가: state.frame(Event::RecoveryEntry(RecoveryEntry {
556추가: candidate_id: 0,
557추가: source_offset: 0,
558추가: name: Some("내용.txt".into()),
559추가: kind: Some(worker_protocol::protocol::EntryKind::File),
560추가: status: RecoveryStatus::Verified,
561추가: reason: RecoveryReason::MetadataMissing,
562추가: declared_size: Some(0),
563추가: verified_size: Some(0),
564추가: sha256: Some([1; 32]),
565추가: }));
566추가: state.frame(Event::RecoveryEnd(RecoveryEnd {
567추가: mode: RecoveryMode::LocalChain,
568추가: source_bytes: 128,
569추가: source_sha256: [2; 32],
570추가: known_entries: None,
571추가: verified_entries: 1,
572추가: lost_entries: 0,
573추가: unverified_entries: 0,
574추가: unknown_loss: true,
575추가: }));
576추가: state.frame(Event::Output {
577추가: entry_id: None,
578추가: relative_name: "복구본.zip".into(),
579추가: disposition: Disposition::Created,
580추가: });
581추가: state.frame(Event::Terminal(Terminal {
582추가: outcome: Outcome::Failed,
583추가: error: Some(ErrorCode::RecoveryIncomplete),
584추가: publication: Publication::Complete,
585추가: created_count: 1,
586추가: retained_partial_count: 0,
587추가: durability: Durability::Synced,
588추가: cleanup: Cleanup::Complete,
589추가: }));
590추가: state.queue.extend([
591추가: HostEvent::StdoutEof,
592추가: HostEvent::StderrEof,
593추가: HostEvent::Exited { success: true },
594추가: ]);
595추가: }
596추가: pump(&mut app.model);
597추가: assert!(app.model.confirmed, "{:?}", app.model.error);
598추가: click(&ctx, &mut app, "복구본 열기");
599추가: assert!(
600추가: matches!(factory.state.borrow().starts.last(), Some(Start::List { archive }) if archive == &output)
601추가: );
602추가: let labels = render(&ctx, &mut app, vec![]);
603추가: assert!(
604추가: labels
605추가: .iter()
606추가: .any(|(text, _)| text.contains("전체 목록을 알 수 없어"))
607추가: );
608추가: }
609추가:
506610 fn loaded(scratch: &Folder, factory: &FakeFactory) -> ArchiveApp {
507611 let mut app = ArchiveApp::new(
508612 Box::new(factory.clone()),
추가tests/rust-app-ui/recovery.rs+163-0
@@ -0,0 +1,163 @@
1추가: use super::*;
2추가: use worker_protocol::protocol::EntryKind;
3추가:
4추가: fn begin() -> (Model, FakeFactory) {
5추가: let mut model = Model::default();
6추가: let mut factory = FakeFactory::manual();
7추가: assert!(model.begin(
8추가: Start::RecoverZip {
9추가: archive: path("damaged.zip"),
10추가: output_file: path("recovered.zip"),
11추가: },
12추가: &mut factory
13추가: ));
14추가: factory
15추가: .state
16추가: .borrow_mut()
17추가: .frame(Event::Accepted { encryption: false });
18추가: (model, factory)
19추가: }
20추가: fn entry() -> RecoveryEntry {
21추가: RecoveryEntry {
22추가: candidate_id: 0,
23추가: source_offset: 0,
24추가: name: Some("한글.txt".into()),
25추가: kind: Some(EntryKind::File),
26추가: status: RecoveryStatus::Verified,
27추가: reason: RecoveryReason::HeaderRebuilt,
28추가: declared_size: Some(4),
29추가: verified_size: Some(4),
30추가: sha256: Some([1; 32]),
31추가: }
32추가: }
33추가: fn summary(partial: bool) -> RecoveryEnd {
34추가: RecoveryEnd {
35추가: mode: if partial {
36추가: RecoveryMode::LocalChain
37추가: } else {
38추가: RecoveryMode::CentralDirectory
39추가: },
40추가: source_bytes: 128,
41추가: source_sha256: [2; 32],
42추가: known_entries: (!partial).then_some(1),
43추가: verified_entries: 1,
44추가: lost_entries: 0,
45추가: unverified_entries: 0,
46추가: unknown_loss: partial,
47추가: }
48추가: }
49추가: fn result(partial: bool) -> Terminal {
50추가: Terminal {
51추가: outcome: if partial {
52추가: Outcome::Failed
53추가: } else {
54추가: Outcome::Completed
55추가: },
56추가: error: partial.then_some(ErrorCode::RecoveryIncomplete),
57추가: publication: Publication::Complete,
58추가: created_count: 1,
59추가: retained_partial_count: 0,
60추가: durability: Durability::Synced,
61추가: cleanup: Cleanup::Complete,
62추가: }
63추가: }
64추가: fn reports(factory: &FakeFactory, partial: bool) {
65추가: let mut s = factory.state.borrow_mut();
66추가: s.frame(Event::RecoveryEntry(entry()));
67추가: s.frame(Event::RecoveryEnd(summary(partial)));
68추가: s.frame(Event::Output {
69추가: entry_id: None,
70추가: relative_name: "recovered.zip".into(),
71추가: disposition: Disposition::Created,
72추가: });
73추가: s.frame(Event::Terminal(result(partial)));
74추가: }
75추가: fn eof(factory: &FakeFactory) {
76추가: factory.state.borrow_mut().queue.extend([
77추가: HostEvent::StdoutEof,
78추가: HostEvent::StderrEof,
79추가: HostEvent::Exited { success: true },
80추가: ]);
81추가: }
82추가: #[test]
83추가: fn recovery_requires_terminal_both_eofs_and_reap_even_for_saved_partial() {
84추가: for partial in [false, true] {
85추가: let (mut model, factory) = begin();
86추가: reports(&factory, partial);
87추가: for _ in 0..20 {
88추가: model.poll();
89추가: }
90추가: assert!(model.busy());
91추가: assert!(!model.confirmed);
92추가: eof(&factory);
93추가: pump(&mut model);
94추가: assert!(model.confirmed, "{:?}", model.error);
95추가: assert_eq!(model.recovery_end.as_ref().unwrap().unknown_loss, partial);
96추가: assert!(model.entries.is_empty());
97추가: assert!(model.list_id.is_none());
98추가: assert!(!model.can_retry_expanded());
99추가: }
100추가: }
101추가: #[test]
102추가: fn recovery_rejects_wrong_ids_offsets_names_and_unverified_hashes() {
103추가: for change in 0..5 {
104추가: let (mut model, factory) = begin();
105추가: let mut e = entry();
106추가: match change {
107추가: 0 => e.candidate_id = 1,
108추가: 1 => e.name = Some("../outside".into()),
109추가: 2 => e.status = RecoveryStatus::Lost,
110추가: 3 => e.verified_size = Some(5),
111추가: _ => e.name = Some("x".repeat(4097)),
112추가: }
113추가: factory.state.borrow_mut().frame(Event::RecoveryEntry(e));
114추가: for _ in 0..5 {
115추가: model.poll();
116추가: }
117추가: assert!(model.error.is_some(), "{change}");
118추가: assert!(model.recovery_entries.is_empty());
119추가: }
120추가: }
121추가: #[test]
122추가: fn recovery_rejects_duplicate_end_wrong_counts_and_false_success() {
123추가: for change in 0..4 {
124추가: let (mut model, factory) = begin();
125추가: let mut s = factory.state.borrow_mut();
126추가: s.frame(Event::RecoveryEntry(entry()));
127추가: let mut end = summary(change == 3);
128추가: if change == 0 {
129추가: end.verified_entries = 2;
130추가: }
131추가: if change == 1 {
132추가: end.source_bytes = 0;
133추가: }
134추가: s.frame(Event::RecoveryEnd(end));
135추가: if change == 2 {
136추가: s.frame(Event::RecoveryEnd(summary(false)));
137추가: }
138추가: s.frame(Event::Output {
139추가: entry_id: None,
140추가: relative_name: "recovered.zip".into(),
141추가: disposition: Disposition::Created,
142추가: });
143추가: s.frame(Event::Terminal(result(false)));
144추가: drop(s);
145추가: eof(&factory);
146추가: pump(&mut model);
147추가: assert!(!model.confirmed, "{change}");
148추가: assert!(model.error.is_some());
149추가: }
150추가: }
151추가: #[test]
152추가: fn recovery_summary_is_not_a_saved_artifact() {
153추가: let (mut model, factory) = begin();
154추가: let mut s = factory.state.borrow_mut();
155추가: s.frame(Event::RecoveryEntry(entry()));
156추가: s.frame(Event::RecoveryEnd(summary(false)));
157추가: s.frame(Event::Terminal(result(false)));
158추가: drop(s);
159추가: eof(&factory);
160추가: pump(&mut model);
161추가: assert!(!model.confirmed);
162추가: assert!(model.outputs.is_empty());
163추가: }
수정tests/rust-app-ui/regressions.rs+1-0
@@ -5,6 +5,7 @@ mod fake;
55#[cfg(feature = "ui")]
66mod native_dialogs;
77mod preview;
8추가: mod recovery;
89mod split_volumes;
910use fake::*;
1011use std::path::PathBuf;
수정tests/rust-app-ui/scenario_tests.rs+21-0
@@ -95,6 +95,27 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
9595 app.model.error
9696 );
9797 assert!(app.model.input_error.is_none(), "{}", scenario.name);
98추가: if scenario.name.starts_with("recovery-") {
99추가: let expected = match scenario.name {
100추가: "recovery-complete" => "복구본 저장 완료",
101추가: "recovery-partial" => "일부 항목만 복구함",
102추가: "recovery-unknown" => "전체 목록을 알 수 없어",
103추가: "recovery-impossible" => "복구 가능한 항목 없음",
104추가: "recovery-save-error" => "복구본 저장을 완료하지 못했습니다",
105추가: "recovery-cancelled" => "복구를 취소했습니다",
106추가: "recovery-resource" => "이 작업 허용",
107추가: _ => "ZIP 복구 중",
108추가: };
109추가: assert!(labels.contains(expected), "{}: {labels}", scenario.name);
110추가: assert_eq!(
111추가: labels.contains("복구본 열기"),
112추가: matches!(
113추가: scenario.name,
114추가: "recovery-complete" | "recovery-partial" | "recovery-unknown"
115추가: )
116추가: );
117추가: assert!(!labels.contains("100%"));
118추가: }
98119 if scenario.name == "split-archive" {
99120 assert!(app.model.list_id.as_ref().unwrap().is_split());
100121 assert!(!app.model.can_preview());
수정tests/rust-app-ui/scenarios.rs+138-0
@@ -21,6 +21,15 @@ macro_rules! catalog {
2121}
2222
2323catalog! {
24추가: "recovery-progress" => "ZIP 복구 분석과 저장 확인 전 대기",
25추가: "recovery-complete" => "전체 항목을 검증한 복구본 저장 완료",
26추가: "recovery-partial" => "유실 항목이 있는 복구본과 경고",
27추가: "recovery-unknown" => "전체 목록 불명의 추가 유실 경고",
28추가: "recovery-impossible" => "복구 가능한 항목 없음과 출력 없음",
29추가: "recovery-cancelled" => "복구 취소와 출력 없음",
30추가: "recovery-save-error" => "복구 분석 뒤 저장 실패",
31추가: "recovery-resource" => "복구 작업의 자원 승인",
32추가:
2433 "create-sevenzip" => "7z 형식 선택과 LZMA2 및 암호 미지원 안내",
2534 "create-sevenzip-progress" => "7z 만들기 진행과 취소",
2635 "create-sevenzip-complete" => "7z 만들기 완료",
@@ -538,6 +547,135 @@ impl Scenario {
538547 }
539548 _ => {}
540549 }
550추가: if self.name.starts_with("recovery-") {
551추가: let request = Start::RecoverZip {
552추가: archive,
553추가: output_file: base.join("복구본.zip"),
554추가: };
555추가: app.last_request = Some(request.clone());
556추가: app.model.begin(request, app.factory.as_mut());
557추가: let mut state = state.borrow_mut();
558추가: state.frame(Event::Accepted { encryption: false });
559추가: if self.name == "recovery-resource" {
560추가: state.frame(Event::ResourceRequired(ResourceChallenge {
561추가: id: 1,
562추가: action: ActionKind::RecoverZip,
563추가: scope: ResourceScope {
564추가: ratio: true,
565추가: ..Default::default()
566추가: },
567추가: usage: ResourceUsage::default(),
568추가: soft_limits: Limits::default(),
569추가: ceiling: Limits::default(),
570추가: }));
571추가: } else if self.name == "recovery-progress" {
572추가: state.frame(Event::Progress {
573추가: stage: Stage::Scan,
574추가: processed: 1024,
575추가: total: None,
576추가: completed_entries: 1,
577추가: });
578추가: } else if self.name == "recovery-cancelled" {
579추가: state.finish(Outcome::Cancelled, Publication::None);
580추가: } else {
581추가: let impossible = self.name == "recovery-impossible";
582추가: let partial = self.name == "recovery-partial";
583추가: let unknown = self.name == "recovery-unknown";
584추가: let failed = self.name == "recovery-save-error";
585추가: state.frame(Event::RecoveryEntry(RecoveryEntry {
586추가: candidate_id: 0,
587추가: source_offset: 0,
588추가: name: Some("읽어주세요.txt".into()),
589추가: kind: Some(worker_protocol::protocol::EntryKind::File),
590추가: status: if impossible {
591추가: RecoveryStatus::Lost
592추가: } else {
593추가: RecoveryStatus::Verified
594추가: },
595추가: reason: if impossible {
596추가: RecoveryReason::Truncated
597추가: } else {
598추가: RecoveryReason::HeaderRebuilt
599추가: },
600추가: declared_size: Some(4),
601추가: verified_size: (!impossible).then_some(4),
602추가: sha256: (!impossible).then_some([1; 32]),
603추가: }));
604추가: if partial {
605추가: state.frame(Event::RecoveryEntry(RecoveryEntry {
606추가: candidate_id: 1,
607추가: source_offset: 128,
608추가: name: Some("사진.png".into()),
609추가: kind: Some(worker_protocol::protocol::EntryKind::File),
610추가: status: RecoveryStatus::Lost,
611추가: reason: RecoveryReason::CrcMismatch,
612추가: declared_size: Some(10),
613추가: verified_size: None,
614추가: sha256: None,
615추가: }));
616추가: }
617추가: state.frame(Event::RecoveryEnd(RecoveryEnd {
618추가: mode: if unknown {
619추가: RecoveryMode::LocalChain
620추가: } else {
621추가: RecoveryMode::CentralDirectory
622추가: },
623추가: source_bytes: 256,
624추가: source_sha256: [2; 32],
625추가: known_entries: (!unknown).then_some(if partial { 2 } else { 1 }),
626추가: verified_entries: u32::from(!impossible),
627추가: lost_entries: u32::from(impossible || partial),
628추가: unverified_entries: 0,
629추가: unknown_loss: unknown,
630추가: }));
631추가: if !impossible && !failed {
632추가: state.frame(Event::Output {
633추가: entry_id: None,
634추가: relative_name: "복구본.zip".into(),
635추가: disposition: Disposition::Created,
636추가: });
637추가: }
638추가: state.frame(Event::Terminal(Terminal {
639추가: outcome: if partial || unknown || impossible || failed {
640추가: Outcome::Failed
641추가: } else {
642추가: Outcome::Completed
643추가: },
644추가: error: if failed {
645추가: Some(ErrorCode::DiskFull)
646추가: } else if impossible {
647추가: Some(ErrorCode::RecoveryImpossible)
648추가: } else if partial || unknown {
649추가: Some(ErrorCode::RecoveryIncomplete)
650추가: } else {
651추가: None
652추가: },
653추가: publication: if impossible || failed {
654추가: Publication::None
655추가: } else {
656추가: Publication::Complete
657추가: },
658추가: created_count: u64::from(!impossible && !failed),
659추가: retained_partial_count: 0,
660추가: durability: if impossible || failed {
661추가: Durability::NotApplicable
662추가: } else {
663추가: Durability::Synced
664추가: },
665추가: cleanup: Cleanup::Complete,
666추가: }));
667추가: state.queue.extend([
668추가: HostEvent::StdoutEof,
669추가: HostEvent::StderrEof,
670추가: HostEvent::Exited { success: true },
671추가: ]);
672추가: }
673추가: drop(state);
674추가: for _ in 0..30 {
675추가: app.model.poll();
676추가: }
677추가: return app;
678추가: }
541679 let seven_zip = self.name.starts_with("create-sevenzip");
542680 let creating = self.name.starts_with("create-") || self.name == "password-create";
543681 let listing_error = matches!(self.name, "unsupported" | "damaged");