team-ljyzipelo

공개

분할 7z 사본의 할당량 초과 시 대체 위치를 재시도함

작성자
시로사키 하나
작성 시각
커밋
fc88a1f7655af287b20d130f84e50b9e7512ed21
이 시점의 파일 보기

변경된 파일 9개

+372-35
수정docs/ui-scenario-guide.md+3-0
@@ -66,6 +66,9 @@ cargo +1.99.1 build --locked --manifest-path experiments/rust-ui-memory-app/Carg
6666- create-complete: ZIP 만들기 완료. 압축 해제 완료와 다른 문구를 확인한다.
6767- folder-empty: 빈 하위 폴더. 목록의 빈 폴더 안내를 확인한다.
6868- gzip-conflict: 단일 GZ 이름 충돌. 다른 이름으로 저장 버튼과 안내를 확인한다.
69추가: - extract-disk-full: 압축 해제의 원본 사본 또는 단계 임시 파일을 쓰는 도중 디스크 공간이나 할당량이 부족한 상황입니다. 공간 확보 후 재시도 안내와 "아무 파일도 풀지 않았습니다"를 확인합니다. ZIP 만들기 화면이 아닌 압축 해제 실패 화면이어야 합니다.
70추가: - extract-complete-cleanup-failed: 압축 해제와 파일 저장은 완료됐지만 출력 폴더의 임시 파일 정리에 실패한 상황입니다. "압축을 풀었습니다"와 저장 위치를 유지하면서 임시 파일이 남을 수 있다는 경고가 함께 표시되는지 확인합니다. 해제 실패나 출력 없음으로 안내하지 않아야 합니다.
71추가: - extract-cleanup-failed: 압축 해제 실패 뒤 출력 폴더의 임시 파일 이름을 지우지 못한 상황입니다. 파일 접근 오류와 함께 풀 위치 폴더에 임시 파일이 남을 수 있다는 경고를 확인합니다. 게시된 파일이 없어도 정리 실패를 표시하며, "아무 파일도 풀지 않았습니다"로 잔여 파일이 없다고 단정하지 않아야 합니다.
6972- extract-partial: 일부 추출 후 실패. 이미 풀린 파일이 남는다는 경고를 확인한다.
7073- extract-uncertain: 저장 여부 불확실. 결과 확인을 권하는 경고를 확인한다.
7174- extract-unsynced: 완료 뒤 저장 확인 미완료. 완료 안내를 유지하고 자세히 보기에 경고가 있는지 확인한다.
수정experiments/rust-archive-worker/src/split_seven_zip.rs+38-22
@@ -336,6 +336,34 @@ impl Group {
336336 self.matches(part, &named)?;
337337 Ok(hash.finalize().into())
338338 }
339추가: fn capture(
340추가: &mut self,
341추가: step: &mut impl FnMut(Step) -> std::result::Result<(), ErrorCode>,
342추가: ) -> Result<(File, [u8; 32])> {
343추가: step(Step::Check)?;
344추가: let mut file = crate::spool::temporary()?;
345추가: crate::space::ensure(&file, self.total)?;
346추가: let mut processed = 0;
347추가: let mut whole = Sha256::new();
348추가: let mut reported = Instant::now();
349추가: for index in 0..self.parts.len() {
350추가: let hash = self.read_part(
351추가: &self.parts[index],
352추가: &mut Some(&mut file),
353추가: &mut whole,
354추가: &mut processed,
355추가: &mut reported,
356추가: step,
357추가: )?;
358추가: self.parts[index].hash = hash;
359추가: step(Step::Activity)?;
360추가: }
361추가: step(Step::Read {
362추가: bytes: processed,
363추가: total: self.total,
364추가: })?;
365추가: Ok((file, whole.finalize().into()))
366추가: }
339367 fn manifest(&self) -> Result<[u8; 32]> {
340368 let mut hash = Sha256::new();
341369 hash.update(b"zipelo.split7z.v1\0");
@@ -511,28 +539,16 @@ pub(crate) fn open(
511539 if group.total > limit {
512540 return Err(ErrorCode::Limit.into());
513541 }
514삭제: let mut file = crate::spool::temporary()?;
515삭제: crate::space::ensure(&file, group.total)?;
516삭제: let mut processed = 0;
517삭제: let mut whole = Sha256::new();
518삭제: let mut reported = Instant::now();
519삭제: for index in 0..group.parts.len() {
520삭제: let hash = group.read_part(
521삭제: &group.parts[index],
522삭제: &mut Some(&mut file),
523삭제: &mut whole,
524삭제: &mut processed,
525삭제: &mut reported,
526삭제: step,
527삭제: )?;
528삭제: group.parts[index].hash = hash;
529삭제: step(Step::Activity)?;
530삭제: }
531삭제: step(Step::Read {
532삭제: bytes: processed,
533삭제: total: group.total,
534삭제: })?;
535삭제: let hash = whole.finalize().into();
542추가: let (mut file, hash) = loop {
543추가: match group.capture(step) {
544추가: Err(failure)
545추가: if failure.error == ErrorCode::DiskFull && crate::spool::next_after_full()? =>
546추가: {
547추가: continue;
548추가: }
549추가: result => break result?,
550추가: }
551추가: };
536552 let object = SourceObject::SplitSevenZip {
537553 manifest_sha256: group.manifest()?,
538554 };
수정experiments/rust-archive-worker/src/spool.rs+9-3
@@ -92,7 +92,7 @@ fn cache_directory() -> Result<filesystem::Dir> {
9292 .ok_or(ErrorCode::Io)
9393 }
9494}
95삭제: fn next_after_full() -> Result<bool> {
95추가: pub(crate) fn next_after_full() -> Result<bool> {
9696 LOCATION.with(|location| {
9797 let mut location = location.borrow_mut();
9898 match location.as_mut() {
@@ -146,9 +146,15 @@ pub(crate) fn temporary() -> Result<File> {
146146 match location.as_mut() {
147147 Some(Placement::Fixed(dir)) => match dir.temporary() {
148148 Ok(file) => Some(Ok(file)),
149삭제: Err(_) => {
149추가: Err(error) => {
150150 *location = None;
151삭제: None
151추가: Some(system_temporary().map_err(|fallback| {
152추가: if error == ErrorCode::DiskFull {
153추가: ErrorCode::DiskFull
154추가: } else {
155추가: fallback
156추가: }
157추가: }))
152158 }
153159 },
154160 Some(Placement::Fallback {
수정experiments/rust-ui-memory-app/src/archive_screen.rs+3-1
@@ -2323,7 +2323,9 @@ impl ArchiveApp {
23232323 let success = self.model.confirmed
23242324 && self.model.error.is_none()
23252325 && t.as_ref().is_some_and(|t| t.outcome == Outcome::Completed)
2326삭제: && warnings.is_empty();
2326추가: && warnings
2327추가: .iter()
2328추가: .all(|warning| !creating && *warning == present::CLEANUP_WARNING);
23272329 let durability_warning = t
23282330 .as_ref()
23292331 .filter(|_| self.model.confirmed && !listing)
수정tests/rust-app-ui/scenario_tests.rs+72-0
@@ -164,6 +164,9 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
164164 "tar-bz2" | "tar-xz" => "읽어주세요.txt",
165165 "folder-empty" => "이 폴더는 비어 있습니다",
166166 "dialog-error" => "파일 선택 창을 열 수 없습니다",
167추가: "extract-complete-cleanup-failed" => "압축을 풀었습니다",
168추가: "extract-disk-full" => "디스크 여유 공간이 부족합니다",
169추가: "extract-cleanup-failed" => "풀 위치 폴더에 남은 임시 파일이 있을 수 있습니다",
167170 "extract-partial" => "일부 파일만 풀렸습니다",
168171 "extract-uncertain" => "저장이 끝났는지 확인하지 못했습니다",
169172 "extract-unsynced" => "파일을 디스크에 완전히 저장했는지 확인하지 못했습니다",
@@ -190,6 +193,75 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
190193 _ => "읽어주세요.txt",
191194 };
192195 assert!(labels.contains(expected), "{}: {labels}", scenario.name);
196추가: if scenario.name == "extract-complete-cleanup-failed" {
197추가: use zipelo_ui_memory_app::archive_ui::{
198추가: Cleanup, Disposition, Outcome, Publication,
199추가: };
200추가: let terminal = app.model.terminal.as_ref().unwrap();
201추가: assert!(app.model.confirmed);
202추가: assert_eq!(terminal.outcome, Outcome::Completed);
203추가: assert_eq!(terminal.error, None);
204추가: assert_eq!(terminal.publication, Publication::Complete);
205추가: assert_eq!(terminal.cleanup, Cleanup::Failed);
206추가: assert_eq!(terminal.created_count, app.model.outputs.len() as u64);
207추가: assert!(app
208추가: .model
209추가: .outputs
210추가: .iter()
211추가: .all(|(_, state)| *state == Disposition::Created));
212추가: assert!(labels.contains("폴더에 저장했습니다"), "{labels}");
213추가: assert!(labels.contains("임시 파일을 지우지 못했습니다"), "{labels}");
214추가: assert!(
215추가: labels.contains("풀 위치 폴더에 남은 임시 파일이 있을 수 있습니다"),
216추가: "{labels}"
217추가: );
218추가: assert!(!labels.contains("압축을 풀지 못했습니다"), "{labels}");
219추가: assert!(!labels.contains("아무 파일도 풀지 않았습니다"), "{labels}");
220추가: }
221추가: if matches!(
222추가: scenario.name,
223추가: "extract-disk-full" | "extract-cleanup-failed"
224추가: ) {
225추가: use zipelo_ui_memory_app::archive_ui::{Cleanup, ErrorCode, Outcome, Publication};
226추가: let cleanup_failed = scenario.name == "extract-cleanup-failed";
227추가: let terminal = app.model.terminal.as_ref().unwrap();
228추가: assert!(app.model.confirmed);
229추가: assert_eq!(terminal.outcome, Outcome::Failed);
230추가: assert_eq!(terminal.publication, Publication::None);
231추가: assert_eq!(terminal.created_count, 0);
232추가: assert_eq!(terminal.retained_partial_count, 0);
233추가: assert_eq!(
234추가: terminal.error,
235추가: Some(if cleanup_failed {
236추가: ErrorCode::Io
237추가: } else {
238추가: ErrorCode::DiskFull
239추가: })
240추가: );
241추가: assert_eq!(
242추가: terminal.cleanup,
243추가: if cleanup_failed {
244추가: Cleanup::Failed
245추가: } else {
246추가: Cleanup::Complete
247추가: }
248추가: );
249추가: assert!(labels.contains("압축을 풀지 못했습니다"), "{labels}");
250추가: assert!(!labels.contains("압축을 풀었습니다"), "{labels}");
251추가: assert_eq!(
252추가: labels.contains("임시 파일을 지우지 못했습니다"),
253추가: cleanup_failed
254추가: );
255추가: if cleanup_failed {
256추가: assert!(!labels.contains("아무 파일도 풀지 않았습니다"), "{labels}");
257추가: } else {
258추가: assert!(
259추가: labels.contains("공간을 확보한 뒤 다시 시도하세요"),
260추가: "{labels}"
261추가: );
262추가: assert!(labels.contains("아무 파일도 풀지 않았습니다"), "{labels}");
263추가: }
264추가: }
193265 if scenario.name == "extract-rename-failed" {
194266 assert!(labels.contains("파일을 읽거나 쓰지 못했습니다"), "{labels}");
195267 assert!(!labels.contains("이름 바꿔 저장:"), "{labels}");
수정tests/rust-app-ui/scenarios.rs+34-2
@@ -90,6 +90,9 @@ catalog! {
9090 "create-complete" => "ZIP 만들기 완료",
9191 "folder-empty" => "항목이 없는 하위 폴더",
9292 "gzip-conflict" => "단일 GZ 파일 이름 충돌",
93추가: "extract-disk-full" => "압축 해제 중 디스크 공간 또는 할당량 부족",
94추가: "extract-complete-cleanup-failed" => "압축 해제 완료와 출력 폴더의 임시 파일 정리 실패",
95추가: "extract-cleanup-failed" => "압축 해제 실패와 출력 폴더의 임시 파일 정리 실패",
9396 "extract-partial" => "일부 파일만 풀린 결과",
9497 "extract-uncertain" => "저장 여부를 확인할 수 없는 결과",
9598 "extract-unsynced" => "완료 뒤 저장 확인 경고의 상세 정보",
@@ -902,7 +905,8 @@ impl Scenario {
902905 "extract-complete"
903906 | "create-complete"
904907 | "create-sevenzip-complete"
905삭제: | "extract-unsynced" => {
908추가: | "extract-unsynced"
909추가: | "extract-complete-cleanup-failed" => {
906910 let names = app.targets.as_ref().unwrap();
907911 for name in names {
908912 state.frame(Event::Output {
@@ -922,7 +926,11 @@ impl Scenario {
922926 } else {
923927 Durability::Synced
924928 },
925삭제: cleanup: Cleanup::Complete,
929추가: cleanup: if self.name == "extract-complete-cleanup-failed" {
930추가: Cleanup::Failed
931추가: } else {
932추가: Cleanup::Complete
933추가: },
926934 }));
927935 state.queue.extend([
928936 HostEvent::StdoutEof,
@@ -961,6 +969,30 @@ impl Scenario {
961969 HostEvent::Exited { success: true },
962970 ]);
963971 }
972추가: "extract-disk-full" | "extract-cleanup-failed" => {
973추가: state.frame(Event::Terminal(Terminal {
974추가: outcome: Outcome::Failed,
975추가: error: Some(if self.name == "extract-disk-full" {
976추가: ErrorCode::DiskFull
977추가: } else {
978추가: ErrorCode::Io
979추가: }),
980추가: publication: Publication::None,
981추가: created_count: 0,
982추가: retained_partial_count: 0,
983추가: durability: Durability::NotApplicable,
984추가: cleanup: if self.name == "extract-cleanup-failed" {
985추가: Cleanup::Failed
986추가: } else {
987추가: Cleanup::Complete
988추가: },
989추가: }));
990추가: state.queue.extend([
991추가: HostEvent::StdoutEof,
992추가: HostEvent::StderrEof,
993추가: HostEvent::Exited { success: true },
994추가: ]);
995추가: }
964996 "conflict"
965997 | "gzip-conflict"
966998 | "unsupported"
수정tests/rust-archive-worker/io_fault.c+9-0
@@ -55,6 +55,15 @@ int openat(int fd, const char *path, int flags, ...) {
5555 va_end(args);
5656 }
5757 const char *fault = getenv("ZIPELO_TEST_FAULT");
58추가: if (fault && !strncmp(fault, "destination-", 12)
59추가: && (((flags & O_TMPFILE) == O_TMPFILE) || ((flags & O_CREAT) && spool_name(path)))) {
60추가: if (strstr(fault, "named") && (flags & O_TMPFILE) == O_TMPFILE) {
61추가: errno = EOPNOTSUPP;
62추가: } else {
63추가: errno = strstr(fault, "edquot") ? EDQUOT : strstr(fault, "denied") ? EACCES : ENOSPC;
64추가: }
65추가: return -1;
66추가: }
5867 if (fault && (!strcmp(fault, "create-full") || !strcmp(fault, "create-denied"))
5968 && !strncmp(path, ".zipelo-", 8)) {
6069 errno = !strcmp(fault, "create-full") ? ENOSPC : EACCES;
수정tests/rust-archive-worker/spool_fallback.rs+121-3
@@ -18,6 +18,7 @@ impl Drop for Running {
1818const PAYLOAD: &[u8] = b"spool fallback preview\n";
1919struct Case {
2020 scratch: Scratch,
21추가: archive_names: Vec<String>,
2122}
2223impl Case {
2324 fn new() -> Self {
@@ -40,7 +41,23 @@ impl Case {
4041 .unwrap()
4142 .success()
4243 );
43삭제: Self { scratch }
44추가: Self {
45추가: scratch,
46추가: archive_names: vec!["input.7z".into(), "input.zip".into()],
47추가: }
48추가: }
49추가: fn split(&mut self) -> (NativePath, Vec<(PathBuf, Vec<u8>)>) {
50추가: let bytes = fs::read(self.archive("7z").to_path().unwrap()).unwrap();
51추가: let mut originals = Vec::new();
52추가: for (index, chunk) in bytes.chunks(bytes.len().div_ceil(9)).enumerate() {
53추가: let name = format!("split.7z.{:03}", index + 1);
54추가: let path = self.scratch.0.join("archive").join(&name);
55추가: fs::write(&path, chunk).unwrap();
56추가: originals.push((path, chunk.to_vec()));
57추가: self.archive_names.push(name);
58추가: }
59추가: self.archive_names.sort();
60추가: (self.scratch.path("archive/split.7z.001"), originals)
4461 }
4562 fn run(&self, action: Action, phase: &str, mask: u8, named: bool) -> Vec<Message> {
4663 let s = &self.scratch;
@@ -62,7 +79,12 @@ impl Case {
6279 if phase == "changed" {
6380 command.env(
6481 "ZIPELO_SPOOL_SOURCE",
65삭제: self.archive("zip").to_path().unwrap(),
82추가: match &action {
83추가: Action::List { archive } | Action::Preview { archive, .. } => {
84추가: archive.to_path().unwrap()
85추가: }
86추가: _ => panic!("source mutation requires an archive"),
87추가: },
6688 );
6789 }
6890 if phase != "real" {
@@ -186,7 +208,12 @@ impl Case {
186208 assert_eq!(fs::read_dir(&path).unwrap().count(), 0, "{path:?}");
187209 }
188210 }
189삭제: assert_eq!(fs::read_dir(root.join("archive")).unwrap().count(), 2);
211추가: let mut names: Vec<_> = fs::read_dir(root.join("archive"))
212추가: .unwrap()
213추가: .map(|entry| entry.unwrap().file_name().into_string().unwrap())
214추가: .collect();
215추가: names.sort();
216추가: assert_eq!(names, self.archive_names);
190217 }
191218 fn preview(&self, format: &str, phase: &str, mask: u8, named: bool) -> Vec<Message> {
192219 let events = self.list(format, phase, mask, named);
@@ -271,6 +298,97 @@ fn cache_source_and_system_locations_retry_creation_space_and_partial_quota_writ
271298 }
272299 }
273300}
301추가: #[test]
302추가: fn split_seven_zip_retries_all_locations_after_partial_quota_writes() {
303추가: use sha2::{Digest, Sha256};
304추가: for named in [false, true] {
305추가: for phase in ["write", "space", "create"] {
306추가: for mask in [1, 3, 7] {
307추가: let mut c = Case::new();
308추가: let (archive, originals) = c.split();
309추가: assert_eq!(originals.len(), 9);
310추가: let bytes = fs::read(c.archive("7z").to_path().unwrap()).unwrap();
311추가: let zip = fs::read(c.archive("zip").to_path().unwrap()).unwrap();
312추가: let events = c.run(Action::List { archive }, phase, mask, named);
313추가: if mask == 7 {
314추가: assert_eq!(
315추가: terminal(&events).outcome,
316추가: Outcome::Failed,
317추가: "{phase}/{named}: {events:?}"
318추가: );
319추가: assert_eq!(terminal(&events).error, ErrorCode::DiskFull, "{events:?}");
320추가: assert!(!events.iter().any(|e| matches!(e, Message::ListEnd { .. })));
321추가: } else {
322추가: assert_eq!(
323추가: terminal(&events).outcome,
324추가: Outcome::Completed,
325추가: "{phase}/{mask}/{named}: {events:?}"
326추가: );
327추가: let id = events
328추가: .iter()
329추가: .find_map(|e| match e {
330추가: Message::ListEnd { list_id, .. } => Some(list_id),
331추가: _ => None,
332추가: })
333추가: .unwrap();
334추가: assert_eq!(id.catalog_version, 2);
335추가: assert_eq!(id.format, Format::SevenZip);
336추가: assert_eq!(id.archive_bytes, bytes.len() as u64);
337추가: assert_eq!(
338추가: id.archive_sha256.as_slice(),
339추가: Sha256::digest(&bytes).as_slice()
340추가: );
341추가: assert!(matches!(
342추가: id.source_object,
343추가: SourceObject::SplitSevenZip { .. }
344추가: ));
345추가: assert!(events.iter().any(
346추가: |e| matches!(e, Message::Entry(entry) if entry.name == "preview.txt")
347추가: ));
348추가: }
349추가: let trace = fs::read_to_string(c.scratch.0.join("trace")).unwrap();
350추가: for at in if mask == 1 {
351추가: &['0', '1'][..]
352추가: } else {
353추가: &['0', '1', '2'][..]
354추가: } {
355추가: assert!(trace.contains(*at), "{phase}/{mask}/{named}: {trace}");
356추가: }
357추가: if mask == 1 {
358추가: assert!(!trace.contains('2'), "{trace}");
359추가: }
360추가: for (path, original) in originals {
361추가: assert_eq!(fs::read(path).unwrap(), original);
362추가: }
363추가: assert_eq!(fs::read(c.archive("7z").to_path().unwrap()).unwrap(), bytes);
364추가: assert_eq!(fs::read(c.archive("zip").to_path().unwrap()).unwrap(), zip);
365추가: }
366추가: }
367추가: }
368추가: }
369추가:
370추가: #[test]
371추가: fn split_source_change_during_failed_copy_prevents_retry_success() {
372추가: for named in [false, true] {
373추가: let mut c = Case::new();
374추가: let (archive, originals) = c.split();
375추가: let events = c.run(Action::List { archive }, "changed", 1, named);
376추가: assert_eq!(terminal(&events).outcome, Outcome::Failed, "{events:?}");
377추가: assert_eq!(
378추가: terminal(&events).error,
379추가: ErrorCode::SourceChanged,
380추가: "{events:?}"
381추가: );
382추가: assert!(!events.iter().any(|e| matches!(e, Message::ListEnd { .. })));
383추가: for (index, (path, mut bytes)) in originals.into_iter().enumerate() {
384추가: if index == 0 {
385추가: bytes.push(b'x');
386추가: }
387추가: assert_eq!(fs::read(path).unwrap(), bytes);
388추가: }
389추가: }
390추가: }
391추가:
274392#[test]
275393fn disk_full_requires_exhausting_all_three_locations_and_io_errors_stay_io() {
276394 for phase in ["create", "space", "write"] {
수정tests/rust-archive-worker/spool_location.rs+83-4
@@ -3,11 +3,41 @@ use super::*;
33// 해제 작업의 원본 사본과 단계 임시 파일은 시스템 임시 폴더가 아니라 출력 폴더에 둠.
44// 시스템 임시 폴더를 쓸 수 없게 만들어도(/tmp 할당량 초과와 같은 상황) 해제가 성공해야 함.
55fn extract_without_system_temp(bytes: &[u8]) -> (Scratch, Vec<Message>) {
6추가: extract_unusable_system_temp(bytes, None, false)
7추가: }
8추가: fn extract_unusable_system_temp(
9추가: bytes: &[u8],
10추가: fault: Option<&str>,
11추가: file_at_temp_path: bool,
12추가: ) -> (Scratch, Vec<Message>) {
613 let s = Scratch::new();
714 let start = encrypted_start(&s, bytes);
8삭제: let mut child = s
9삭제: .worker()
10삭제: .env("TMPDIR", s.0.join("missing-temp"))
15추가: let temp = s.0.join("missing-temp");
16추가: if file_at_temp_path {
17추가: fs::write(&temp, b"keep").unwrap();
18추가: }
19추가: let mut command = s.worker();
20추가: command.env("TMPDIR", &temp);
21추가: if let Some(fault) = fault {
22추가: let shim = s.0.join("io_fault.so");
23추가: assert!(
24추가: Command::new("cc")
25추가: .args(["-shared", "-fPIC", "-O2", "-Wall", "-Wextra", "-Werror"])
26추가: .arg(
27추가: PathBuf::from(env!("CARGO_MANIFEST_DIR"))
28추가: .join("../../tests/rust-archive-worker/io_fault.c")
29추가: )
30추가: .args(["-ldl", "-o"])
31추가: .arg(&shim)
32추가: .status()
33추가: .unwrap()
34추가: .success()
35추가: );
36추가: command
37추가: .env("LD_PRELOAD", shim)
38추가: .env("ZIPELO_TEST_FAULT", fault);
39추가: }
40추가: let mut child = command
1141 .stdin(Stdio::piped())
1242 .stdout(Stdio::piped())
1343 .stderr(Stdio::piped())
@@ -37,7 +67,11 @@ fn extract_without_system_temp(bytes: &[u8]) -> (Scratch, Vec<Message>) {
3767 let output = child.wait_with_output().unwrap();
3868 assert!(output.status.success(), "{:?}", output.stderr);
3969 assert!(output.stderr.is_empty());
40삭제: assert!(!s.0.join("missing-temp").exists());
70추가: if file_at_temp_path {
71추가: assert_eq!(fs::read(&temp).unwrap(), b"keep");
72추가: } else {
73추가: assert!(!temp.exists());
74추가: }
4175 (s, events)
4276}
4377
@@ -101,3 +135,48 @@ fn corrupt_archive_error_wins_over_read_only_destination() {
101135 assert_eq!(terminal(&events).cleanup, Cleanup::Complete);
102136 assert_eq!(fs::read_dir(&output).unwrap().count(), 0);
103137}
138추가:
139추가: #[test]
140추가: fn destination_space_or_quota_failure_survives_unusable_system_temp() {
141추가: let input = include_bytes!("fixtures/deflate.zip");
142추가: for fault in [
143추가: "destination-enospc",
144추가: "destination-edquot",
145추가: "destination-named-enospc",
146추가: "destination-named-edquot",
147추가: ] {
148추가: for file in [false, true] {
149추가: let (s, events) = extract_unusable_system_temp(input, Some(fault), file);
150추가: let terminal = terminal(&events);
151추가: assert_eq!(
152추가: terminal.outcome,
153추가: Outcome::Failed,
154추가: "{fault}/{file}: {events:?}"
155추가: );
156추가: assert_eq!(
157추가: terminal.error,
158추가: ErrorCode::DiskFull,
159추가: "{fault}/{file}: {events:?}"
160추가: );
161추가: assert_eq!(terminal.publication, Publication::None);
162추가: assert_eq!(terminal.cleanup, Cleanup::Complete);
163추가: assert_eq!(terminal.created_count, 0);
164추가: assert_only_outputs(&s, &[]);
165추가: assert_eq!(fs::read(s.0.join("input")).unwrap(), input);
166추가: }
167추가: }
168추가: }
169추가:
170추가: #[test]
171추가: fn destination_permission_failure_with_unusable_system_temp_stays_io() {
172추가: for file in [false, true] {
173추가: let (s, events) = extract_unusable_system_temp(
174추가: include_bytes!("fixtures/deflate.zip"),
175추가: Some("destination-denied"),
176추가: file,
177추가: );
178추가: assert_eq!(terminal(&events).error, ErrorCode::Io, "{events:?}");
179추가: assert_eq!(terminal(&events).outcome, Outcome::Failed);
180추가: assert_only_outputs(&s, &[]);
181추가: }
182추가: }