복구 임시 파일 잔여 보고를 보존함
- 작성자
- 호시노 히나타
- 작성 시각
- 커밋
adf78d3e8189c01de4a2cb2664b18d88d8818df2- 부모
- fec7fdd
변경된 파일 6개
+150-11| @@ -206,6 +206,7 @@ Ubuntu 제거 안내는 패키지 관리자 터미널 출력입니다. 이전 | ||
| 206 | 206 | - recovery-unknown: 전체 목록을 알 수 없어 추가 유실 여부를 확인할 수 없습니다. |
| 207 | 207 | - recovery-impossible: 복구 가능한 항목과 생성된 복구본이 없습니다. |
| 208 | 208 | - recovery-cancelled: 취소 종료와 출력 없음 상태입니다. |
| 209 | 추가: - recovery-retained: 저장 실패 뒤 남은 임시 파일의 실제 경로와 정리 경고를 표시합니다. 완성된 복구본으로 열지 않습니다. | |
| 209 | 210 | - recovery-save-error: 분석이 끝났어도 저장 실패를 완료로 표시하지 않습니다. |
| 210 | 211 | - recovery-resource: 원본 제한은 유지하면서 압축률 예산 승인을 확인합니다. |
| 211 | 212 |
| @@ -2152,9 +2152,28 @@ impl ArchiveApp { | ||
| 2152 | 2152 | Some(Start::RecoverZip { output_file, .. }) => output_file.clone(), |
| 2153 | 2153 | _ => return, |
| 2154 | 2154 | }; |
| 2155 | 삭제: if saved || !self.model.outputs.is_empty() { | |
| 2155 | 추가: if saved | |
| 2156 | 추가: || self | |
| 2157 | 추가: .model | |
| 2158 | 추가: .outputs | |
| 2159 | 추가: .iter() | |
| 2160 | 추가: .any(|(_, d)| matches!(d, Disposition::Created | Disposition::CommitUncertain)) | |
| 2161 | 추가: { | |
| 2156 | 2162 | theme::bounded_text(ui, &output.display().to_string(), ui.available_width()); |
| 2157 | 2163 | } |
| 2164 | 추가: for (name, _) in self | |
| 2165 | 추가: .model | |
| 2166 | 추가: .outputs | |
| 2167 | 추가: .iter() | |
| 2168 | 추가: .filter(|(_, d)| *d == Disposition::PartialRetained) | |
| 2169 | 추가: { | |
| 2170 | 추가: let retained = output.parent().unwrap_or(Path::new("")).join(name); | |
| 2171 | 추가: theme::bounded_text( | |
| 2172 | 추가: ui, | |
| 2173 | 추가: &format!("남은 임시 파일: {}", retained.display()), | |
| 2174 | 추가: ui.available_width(), | |
| 2175 | 추가: ); | |
| 2176 | 추가: } | |
| 2158 | 2177 | if let Some(error) = &self.model.error { |
| 2159 | 2178 | ui.colored_label(theme::WARNING, error); |
| 2160 | 2179 | } |
| @@ -1343,12 +1343,29 @@ impl Model { | ||
| 1343 | 1343 | entry_id, |
| 1344 | 1344 | } => { |
| 1345 | 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 | 삭제: { | |
| 1346 | 추가: let final_output = matches!( | |
| 1347 | 추가: disposition, | |
| 1348 | 추가: Disposition::Created | Disposition::CommitUncertain | |
| 1349 | 추가: ); | |
| 1350 | 추가: let valid_output = if final_output { | |
| 1351 | 추가: output_file.file_name().and_then(|n| n.to_str()) | |
| 1352 | 추가: == Some(relative_name.as_str()) | |
| 1353 | 추가: && !self.outputs.iter().any(|(_, d)| { | |
| 1354 | 추가: matches!( | |
| 1355 | 추가: d, | |
| 1356 | 추가: Disposition::Created | Disposition::CommitUncertain | |
| 1357 | 추가: ) | |
| 1358 | 추가: }) | |
| 1359 | 추가: } else { | |
| 1360 | 추가: valid_leaf(&relative_name) | |
| 1361 | 추가: && (disposition != Disposition::PartialRetained | |
| 1362 | 추가: || output_file.file_name().and_then(|n| n.to_str()) | |
| 1363 | 추가: != Some(relative_name.as_str())) | |
| 1364 | 추가: && !self.outputs.iter().any(|(name, d)| { | |
| 1365 | 추가: name == &relative_name && *d == disposition | |
| 1366 | 추가: }) | |
| 1367 | 추가: }; | |
| 1368 | 추가: if entry_id.is_some() || self.recovery_end.is_none() || !valid_output { | |
| 1352 | 1369 | self.error = Some("복구본 출력 응답이 유효하지 않습니다".into()); |
| 1353 | 1370 | return; |
| 1354 | 1371 | } |
| @@ -161,3 +161,84 @@ fn recovery_summary_is_not_a_saved_artifact() { | ||
| 161 | 161 | assert!(!model.confirmed); |
| 162 | 162 | assert!(model.outputs.is_empty()); |
| 163 | 163 | } |
| 164 | 추가: | |
| 165 | 추가: #[test] | |
| 166 | 추가: fn recovery_retains_temporary_paths_with_and_without_a_publication_report() { | |
| 167 | 추가: for final_disposition in [ | |
| 168 | 추가: None, | |
| 169 | 추가: Some(Disposition::Created), | |
| 170 | 추가: Some(Disposition::CommitUncertain), | |
| 171 | 추가: ] { | |
| 172 | 추가: let (mut model, factory) = begin(); | |
| 173 | 추가: let mut state = factory.state.borrow_mut(); | |
| 174 | 추가: state.frame(Event::RecoveryEntry(entry())); | |
| 175 | 추가: state.frame(Event::RecoveryEnd(summary(false))); | |
| 176 | 추가: if let Some(disposition) = final_disposition { | |
| 177 | 추가: state.frame(Event::Output { | |
| 178 | 추가: entry_id: None, | |
| 179 | 추가: relative_name: "recovered.zip".into(), | |
| 180 | 추가: disposition, | |
| 181 | 추가: }); | |
| 182 | 추가: } | |
| 183 | 추가: state.frame(Event::Output { | |
| 184 | 추가: entry_id: None, | |
| 185 | 추가: relative_name: ".zipelo-42-1.tmp".into(), | |
| 186 | 추가: disposition: Disposition::PartialRetained, | |
| 187 | 추가: }); | |
| 188 | 추가: state.frame(Event::Terminal(Terminal { | |
| 189 | 추가: outcome: Outcome::Failed, | |
| 190 | 추가: error: Some(ErrorCode::Io), | |
| 191 | 추가: publication: match final_disposition { | |
| 192 | 추가: None => Publication::None, | |
| 193 | 추가: Some(Disposition::Created) => Publication::Partial, | |
| 194 | 추가: _ => Publication::Uncertain, | |
| 195 | 추가: }, | |
| 196 | 추가: created_count: u64::from(final_disposition == Some(Disposition::Created)), | |
| 197 | 추가: retained_partial_count: 1, | |
| 198 | 추가: durability: Durability::Unconfirmed, | |
| 199 | 추가: cleanup: Cleanup::Failed, | |
| 200 | 추가: })); | |
| 201 | 추가: drop(state); | |
| 202 | 추가: eof(&factory); | |
| 203 | 추가: pump(&mut model); | |
| 204 | 추가: assert!(model.confirmed, "{:?}", model.error); | |
| 205 | 추가: assert!( | |
| 206 | 추가: model | |
| 207 | 추가: .outputs | |
| 208 | 추가: .contains(&(".zipelo-42-1.tmp".into(), Disposition::PartialRetained)) | |
| 209 | 추가: ); | |
| 210 | 추가: assert!(!model.can_retry_expanded()); | |
| 211 | 추가: } | |
| 212 | 추가: } | |
| 213 | 추가: | |
| 214 | 추가: #[test] | |
| 215 | 추가: fn recovery_output_validation_still_rejects_wrong_fields_and_duplicates() { | |
| 216 | 추가: for case in 0..6 { | |
| 217 | 추가: let (mut model, factory) = begin(); | |
| 218 | 추가: let mut state = factory.state.borrow_mut(); | |
| 219 | 추가: state.frame(Event::RecoveryEntry(entry())); | |
| 220 | 추가: state.frame(Event::RecoveryEnd(summary(false))); | |
| 221 | 추가: let (entry_id, name, disposition) = match case { | |
| 222 | 추가: 0 => (Some(0), ".zipelo-42-1.tmp", Disposition::PartialRetained), | |
| 223 | 추가: 1 => (None, "../outside.tmp", Disposition::PartialRetained), | |
| 224 | 추가: 2 => (None, "other.zip", Disposition::Created), | |
| 225 | 추가: 3 => (None, "recovered.zip", Disposition::PartialRetained), | |
| 226 | 추가: 4 => (None, "recovered.zip", Disposition::Created), | |
| 227 | 추가: _ => (None, ".zipelo-42-1.tmp", Disposition::PartialRetained), | |
| 228 | 추가: }; | |
| 229 | 추가: let report = Event::Output { | |
| 230 | 추가: entry_id, | |
| 231 | 추가: relative_name: name.into(), | |
| 232 | 추가: disposition, | |
| 233 | 추가: }; | |
| 234 | 추가: state.frame(report.clone()); | |
| 235 | 추가: if case >= 4 { | |
| 236 | 추가: state.frame(report); | |
| 237 | 추가: } | |
| 238 | 추가: drop(state); | |
| 239 | 추가: for _ in 0..20 { | |
| 240 | 추가: model.poll(); | |
| 241 | 추가: } | |
| 242 | 추가: assert!(model.error.is_some(), "{case}"); | |
| 243 | 추가: } | |
| 244 | 추가: } |
| @@ -101,7 +101,9 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() { | ||
| 101 | 101 | "recovery-partial" => "일부 항목만 복구함", |
| 102 | 102 | "recovery-unknown" => "전체 목록을 알 수 없어", |
| 103 | 103 | "recovery-impossible" => "복구 가능한 항목 없음", |
| 104 | 삭제: "recovery-save-error" => "복구본 저장을 완료하지 못했습니다", | |
| 104 | 추가: "recovery-save-error" | "recovery-retained" => { | |
| 105 | 추가: "복구본 저장을 완료하지 못했습니다" | |
| 106 | 추가: } | |
| 105 | 107 | "recovery-cancelled" => "복구를 취소했습니다", |
| 106 | 108 | "recovery-resource" => "이 작업 허용", |
| 107 | 109 | _ => "ZIP 복구 중", |
| @@ -115,6 +117,12 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() { | ||
| 115 | 117 | ) |
| 116 | 118 | ); |
| 117 | 119 | assert!(!labels.contains("100%")); |
| 120 | 추가: if scenario.name == "recovery-retained" { | |
| 121 | 추가: assert!(labels.contains("남은 임시 파일:"), "{labels}"); | |
| 122 | 추가: assert!(labels.contains(".zipelo-42-1.tmp"), "{labels}"); | |
| 123 | 추가: assert!(app.model.confirmed); | |
| 124 | 추가: assert!(!app.model.can_retry_expanded()); | |
| 125 | 추가: } | |
| 118 | 126 | } |
| 119 | 127 | if scenario.name == "split-archive" { |
| 120 | 128 | assert!(app.model.list_id.as_ref().unwrap().is_split()); |
| @@ -27,6 +27,7 @@ catalog! { | ||
| 27 | 27 | "recovery-unknown" => "전체 목록 불명의 추가 유실 경고", |
| 28 | 28 | "recovery-impossible" => "복구 가능한 항목 없음과 출력 없음", |
| 29 | 29 | "recovery-cancelled" => "복구 취소와 출력 없음", |
| 30 | 추가: "recovery-retained" => "복구 저장 실패 뒤 남은 임시 파일 경로와 정리 경고", | |
| 30 | 31 | "recovery-save-error" => "복구 분석 뒤 저장 실패", |
| 31 | 32 | "recovery-resource" => "복구 작업의 자원 승인", |
| 32 | 33 | |
| @@ -581,7 +582,8 @@ impl Scenario { | ||
| 581 | 582 | let impossible = self.name == "recovery-impossible"; |
| 582 | 583 | let partial = self.name == "recovery-partial"; |
| 583 | 584 | let unknown = self.name == "recovery-unknown"; |
| 584 | 삭제: let failed = self.name == "recovery-save-error"; | |
| 585 | 추가: let retained = self.name == "recovery-retained"; | |
| 586 | 추가: let failed = self.name == "recovery-save-error" || retained; | |
| 585 | 587 | state.frame(Event::RecoveryEntry(RecoveryEntry { |
| 586 | 588 | candidate_id: 0, |
| 587 | 589 | source_offset: 0, |
| @@ -635,6 +637,13 @@ impl Scenario { | ||
| 635 | 637 | disposition: Disposition::Created, |
| 636 | 638 | }); |
| 637 | 639 | } |
| 640 | 추가: if retained { | |
| 641 | 추가: state.frame(Event::Output { | |
| 642 | 추가: entry_id: None, | |
| 643 | 추가: relative_name: ".zipelo-42-1.tmp".into(), | |
| 644 | 추가: disposition: Disposition::PartialRetained, | |
| 645 | 추가: }); | |
| 646 | 추가: } | |
| 638 | 647 | state.frame(Event::Terminal(Terminal { |
| 639 | 648 | outcome: if partial || unknown || impossible || failed { |
| 640 | 649 | Outcome::Failed |
| @@ -656,13 +665,17 @@ impl Scenario { | ||
| 656 | 665 | Publication::Complete |
| 657 | 666 | }, |
| 658 | 667 | created_count: u64::from(!impossible && !failed), |
| 659 | 삭제: retained_partial_count: 0, | |
| 668 | 추가: retained_partial_count: u64::from(retained), | |
| 660 | 669 | durability: if impossible || failed { |
| 661 | 670 | Durability::NotApplicable |
| 662 | 671 | } else { |
| 663 | 672 | Durability::Synced |
| 664 | 673 | }, |
| 665 | 삭제: cleanup: Cleanup::Complete, | |
| 674 | 추가: cleanup: if retained { | |
| 675 | 추가: Cleanup::Failed | |
| 676 | 추가: } else { | |
| 677 | 추가: Cleanup::Complete | |
| 678 | 추가: }, | |
| 666 | 679 | })); |
| 667 | 680 | state.queue.extend([ |
| 668 | 681 | HostEvent::StdoutEof, |