건너뛴 파일을 저장 공간 검사에서 제외함
- 작성자
- 시로사키 하나
- 작성 시각
- 커밋
300cd496adea46728afa891d49ad2462f8d98c35- 부모
- 53bf04c
변경된 파일 5개
+256-6| @@ -17,7 +17,7 @@ | ||
| 17 | 17 | revision 2의 기존 필드와 오류 tag 0~12 및 입력/출력 기본 한도를 유지하고, 히나타 님과 합의한 공간 부족 오류 DiskFull(tag 13)을 추가합니다. 구버전 앱은 새 tag를 거부하므로 앱 오류 변환과 화면 매핑을 작업자와 함께 갱신해야 합니다. 앱이 공유하는 Limits::default()도 같은 값을 사용합니다. 세부 계약은 contract.json의 streaming_limits에 있습니다. |
| 18 | 18 | |
| 19 | 19 | - 압축비는 거부 조건으로 사용하지 않습니다. ZIP 선언 크기와 실제 해제 크기, CRC와 AES 인증을 검사하며, GZ 연결 멤버의 전체 해제량도 16 GiB 총량 한도에 포함합니다. TAR.GZ의 헤더와 padding도 계산합니다. u64 누계와 offset은 checked 연산을 사용합니다. |
| 20 | 삭제: - 입력 캡처 전에 임시 저장소 여유 공간을 확인합니다. ZIP/7z 해제 전에는 전체 임시 해제량과 선택한 출력량을 볼륨별로 합산해 검사하고, 게시 전에도 출력 공간을 재검사합니다. 미리 해제 크기를 알 수 없는 GZ/TAR.GZ는 각 해제 청크를 쓰기 전에 임시 저장소 공간을 확인합니다. Linux 64비트는 열린 핸들의 [fstatvfs](https://man7.org/linux/man-pages/man3/fstatvfs.3.html), Windows는 핸들에서 얻은 디렉터리의 [GetDiskFreeSpaceExW](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdiskfreespaceexw)를 사용합니다. 공간 부족은 DiskFull(13), 조회 실패와 권한 등 다른 I/O 오류는 Io(8)로 반환합니다. 실제 생성/쓰기/동기화의 공간 부족에도 같은 구분을 적용합니다. Windows의 공간 부족 코드 39와 112는 [공식 오류 목록](https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-)을 따릅니다. | |
| 20 | 추가: - 입력 캡처 전에 임시 저장소 여유 공간을 확인합니다. 기존 Start는 ZIP/7z 해제 전에 전체 임시 해제량과 선택한 출력량을 볼륨별로 합산해 검사하고, 게시 전에도 출력 공간을 재검사합니다. StartInteractive는 선택 전에는 무결성 검증에 필요한 임시 해제 공간만 확인하고, 선택 뒤 건너뛰지 않은 파일의 실제 저장 이름으로 게시 직전 공간을 확인합니다. 따라서 목적지 공간이 부족해도 충돌 파일을 전부 건너뛰거나 질문 중 취소할 수 있습니다. 미리 해제 크기를 알 수 없는 GZ/TAR.GZ는 각 해제 청크를 쓰기 전에 임시 저장소 공간을 확인합니다. Linux 64비트는 열린 핸들의 [fstatvfs](https://man7.org/linux/man-pages/man3/fstatvfs.3.html), Windows는 핸들에서 얻은 디렉터리의 [GetDiskFreeSpaceExW](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdiskfreespaceexw)를 사용합니다. 공간 부족은 DiskFull(13), 조회 실패와 권한 등 다른 I/O 오류는 Io(8)로 반환합니다. 실제 생성/쓰기/동기화의 공간 부족에도 같은 구분을 적용합니다. Windows의 공간 부족 코드 39와 112는 [공식 오류 목록](https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-)을 따릅니다. | |
| 21 | 21 | - 공간 검사는 논리적 파일 크기에 따른 사전 확인이며 예약이나 모든 메타데이터/할당 단위 비용의 보장이 아닙니다. 다른 작업과 경쟁해 나중에 ENOSPC가 발생하면 기존 부분 출력 정리 정책을 적용합니다. 16 GiB 안에서는 압축비가 매우 큰 파일도 디스크에 풀릴 수 있습니다. 오류 문구는 "디스크 여유 공간이 부족합니다. 공간을 확보한 뒤 다시 시도하세요"이며, detail 문자열을 오류 판정에 사용하지 않습니다. |
| 22 | 22 | - 입력과 검증된 해제 내용은 임시 파일에 저장합니다. Linux는 [O_TMPFILE](https://man7.org/linux/man-pages/man2/open.2.html), 이를 지원하지 않는 Linux 파일시스템에서는 0600 난수 파일을 배타적으로 만든 즉시 unlink하고 링크 수 0을 확인합니다. Windows는 배타적 [DELETE_ON_CLOSE 파일](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew)을 사용합니다. 마지막 핸들이 닫히면 제거되며 임시 파일명에 아카이브 내부 이름을 사용하지 않습니다. 디스크에는 입력 사본, 해제 내용과 현재 출력 임시 파일이 동시에 필요할 수 있습니다. 임시 폴더가 tmpfs이면 해당 파일 내용은 프로세스 RSS 외의 시스템 메모리를 사용합니다. |
| 23 | 23 | - 64 MiB는 ZIP/TAR/GZ/TAR.GZ/7z 해제와 ZIP 생성 작업자 프로세스의 피크 RSS 시험 목표입니다. OS 메모리 강제 격리나 모든 아카이브의 보장을 뜻하지 않습니다. 입력 크기와 무관한 메타데이터 예산은 유지합니다. |
| @@ -166,7 +166,7 @@ | ||
| 166 | 166 | "staging": "64 KiB buffers; immutable input capture and verified decoded content use private temporary files that are removed on last-handle close. No decoded content is published until the entire catalog and integrity checks succeed. Temporary disk usage can include the archive plus expanded content plus current destination temporary file; disk exhaustion fails with DiskFull and closes/removes unpublished data.", |
| 167 | 167 | "legacy": "The slice parser keeps 64 MiB input /128 MiB output caps; the slice ZIP builder keeps 128 MiB source/result caps. Runtime 7z and ZIP creation use streaming file paths.", |
| 168 | 168 | "parent_lifetime": "Capture native parent before reading Start. At decode/read/write/password checkpoints, fail Io if parent is gone; close anonymous staging and remove current unpublished destination temp. stdin EOF alone remains valid for one-shot requests. Already published entries and directories are reported and retained. A blocked OS file operation cannot be forcibly interrupted by this cooperative guard.", |
| 169 | 삭제: "disk_space": "Advisory free-space checks use opened Linux x86_64 filesystem handles (fstatvfs) or the Windows handle-derived directory (GetDiskFreeSpaceExW). Before ZIP/7z decoding and before publication, group remaining staging and selected output logical bytes by volume. For GZip with unknown expanded size, check staging space before each decoded chunk, then preflight selected output. Input capture also checks its snapshot space. Insufficient space returns DiskFull tag 13. Query failure and other I/O errors retain Io tag 8. Checks do not reserve space or account for every metadata/block-allocation overhead; later ENOSPC still closes staging and removes current unpublished output.", | |
| 169 | 추가: "disk_space": "Advisory free-space checks use opened Linux x86_64 filesystem handles (fstatvfs) or the Windows handle-derived directory (GetDiskFreeSpaceExW). Legacy Start groups remaining staging and selected output logical bytes by volume before ZIP/7z decoding and before publication. StartInteractive checks required staging before choices, then checks only the current non-skipped output at its resolved name immediately before publication; do not charge undecided or skipped files to the destination. For GZip with unknown expanded size, check staging space before each decoded chunk, then preflight selected output. Input capture also checks its snapshot space. Insufficient space returns DiskFull tag 13. Query failure and other I/O errors retain Io tag 8. Checks do not reserve space or account for every metadata/block-allocation overhead; later ENOSPC still closes staging and removes current unpublished output.", | |
| 170 | 170 | "remaining_risk": "High compression ratios within 16 GiB may expand fully onto disk. Resource duration, cooperative cancellation and measured memory target remain. Free-space checks can race with other disk users; already published outputs are retained on failure.", |
| 171 | 171 | "seven_zip": "Copy, LZMA and LZMA2 use file-backed solid output with checked declared/actual output totals. Encoded headers remain limited to 8 MiB. Dictionary size remains at most 64 MiB; only the last 8 MiB is cached in memory and older dictionary bytes are read from the temporary output.", |
| 172 | 172 | "create_zip": "The sum of source logical bytes cannot exceed min(input,output) quotas. output defaults to 16 GiB of uncompressed source content; ZIP container/encryption overhead may exceed that logical content quota. Capture one immutable source at a time, stream Store/Deflate and optional AES-256 through 64 KiB buffers, then publish the completed ZIP without replacing existing files. Emit ZIP64 sizes/offsets only when their 32-bit fields would overflow or equal the sentinel. Check staging and destination free space; StorageFull maps to DiskFull tag 13 and other I/O failures retain Io tag 8." |
| @@ -220,6 +220,7 @@ | ||
| 220 | 220 | "overwrite": "Write, verify, sync and close a new owned temporary file in the destination directory before replacing the existing ordinary file. A pre-replacement failure preserves the original. After replacement, report actual publication and durability; do not claim whole-job rollback.", |
| 221 | 221 | "counts": "created_count includes published replacement files and newly created files/directories; excludes skipped files. If all files are skipped and no new directory or other output is created, finish Completed/None with created_count=0 and Durability NotApplicable. Newly created directories retain their Output events and actual counts even if all files are skipped.", |
| 222 | 222 | "implementation_boundary": "Worker supports StartInteractive extraction. Frontend activation and native Windows/Wayland integration require separate verification. Existing Start remains exclusive and aborts on file conflicts.", |
| 223 | 삭제: "target_revalidation": "Before replacement compare parent and file native identities, size and modification time with the question-time observation. Detected changes fail Conflict. This is not atomic compare-and-replace against concurrent writes by the same account." | |
| 223 | 추가: "target_revalidation": "Before replacement compare parent and file native identities, size and modification time with the question-time observation. Detected changes fail Conflict. This is not atomic compare-and-replace against concurrent writes by the same account.", | |
| 224 | 추가: "disk_space": "Required input capture and complete integrity staging checks remain before conflict questions. Defer destination space checks until the current choice is resolved. Skip has no destination byte charge; overwrite, rename and non-conflicting files are checked immediately before their publication. Preserve legacy Start aggregate preflight, limits, per-write checks and partial-output reporting." | |
| 224 | 225 | } |
| 225 | 226 | } |
| @@ -405,7 +405,13 @@ impl<W: Write> Job<W> { | ||
| 405 | 405 | } else { |
| 406 | 406 | None |
| 407 | 407 | }; |
| 408 | 삭제: filesystem::preflight_space(&root, &output_sizes, staged)?; | |
| 408 | 추가: // 선택 전에는 검증에 필요한 스테이징 공간만 계산함. | |
| 409 | 추가: let initial_outputs = if self.interactive { | |
| 410 | 추가: &[][..] | |
| 411 | 추가: } else { | |
| 412 | 추가: &output_sizes[..] | |
| 413 | 추가: }; | |
| 414 | 추가: filesystem::preflight_space(&root, initial_outputs, staged)?; | |
| 409 | 415 | let encrypted = catalog.members.iter().any(|m| m.entry.encrypted); |
| 410 | 416 | if matches!(catalog.format, Format::Zip | Format::SevenZip) { |
| 411 | 417 | for attempt in 1..=3 { |
| @@ -457,7 +463,9 @@ impl<W: Write> Job<W> { | ||
| 457 | 463 | .map(|m| (m.entry.name.clone(), EntryKind::File)), |
| 458 | 464 | ); |
| 459 | 465 | filesystem::preflight_mode(&root, &names, self.interactive)?; |
| 460 | 삭제: filesystem::preflight_space(&root, &output_sizes, None)?; | |
| 466 | 추가: if !self.interactive { | |
| 467 | 추가: filesystem::preflight_space(&root, &output_sizes, None)?; | |
| 468 | 추가: } | |
| 461 | 469 | let mut reserved = names |
| 462 | 470 | .iter() |
| 463 | 471 | .map(|(name, _)| name.to_lowercase()) |
| @@ -509,6 +517,14 @@ impl<W: Write> Job<W> { | ||
| 509 | 517 | continue; |
| 510 | 518 | } |
| 511 | 519 | } |
| 520 | 추가: if self.interactive { | |
| 521 | 추가: // 건너뛴 파일을 제외하고 이번에 게시할 파일의 공간을 확인함. | |
| 522 | 추가: filesystem::preflight_space( | |
| 523 | 추가: &root, | |
| 524 | 추가: &[(name.clone(), m.entry.size)], | |
| 525 | 추가: None, | |
| 526 | 추가: )?; | |
| 527 | 추가: } | |
| 512 | 528 | self.output_reader( |
| 513 | 529 | &root, |
| 514 | 530 | &name, |
| @@ -700,3 +700,231 @@ fn overwrite_does_not_modify_other_hard_links() { | ||
| 700 | 700 | assert_eq!(fs::read(s.0.join("output/a")).unwrap(), PAYLOAD); |
| 701 | 701 | assert_eq!(fs::read(s.0.join("outside")).unwrap(), b"original"); |
| 702 | 702 | } |
| 703 | 추가: | |
| 704 | 추가: #[cfg(target_os = "linux")] | |
| 705 | 추가: #[test] | |
| 706 | 추가: fn skip_all_ignores_destination_space_for_zip_tar_and_gzip() { | |
| 707 | 추가: for format in ["zip", "tar", "gzip"] { | |
| 708 | 추가: for apply in [false, true] { | |
| 709 | 추가: let s = Scratch::new(); | |
| 710 | 추가: let names = match format { | |
| 711 | 추가: "zip" => vec!["a", "b"], | |
| 712 | 추가: "tar" => vec!["folder/hello.txt"], | |
| 713 | 추가: _ => vec!["chosen.txt"], | |
| 714 | 추가: }; | |
| 715 | 추가: fixture(&s, &names); | |
| 716 | 추가: let mut start = request(&s); | |
| 717 | 추가: if format == "tar" { | |
| 718 | 추가: fs::write(s.0.join("input"), include_bytes!("fixtures/sample.tar")).unwrap(); | |
| 719 | 추가: } else if format == "gzip" { | |
| 720 | 추가: fs::write(s.0.join("input"), include_bytes!("fixtures/sample.gz")).unwrap(); | |
| 721 | 추가: if let Action::Extract { | |
| 722 | 추가: gzip_output_name, .. | |
| 723 | 추가: } = &mut start.action | |
| 724 | 추가: { | |
| 725 | 추가: *gzip_output_name = Some("chosen.txt".into()); | |
| 726 | 추가: } | |
| 727 | 추가: } | |
| 728 | 추가: let before = names | |
| 729 | 추가: .iter() | |
| 730 | 추가: .map(|name| hash(&s.0.join("output").join(name))) | |
| 731 | 추가: .collect::<Vec<_>>(); | |
| 732 | 추가: let events = run( | |
| 733 | 추가: &s, | |
| 734 | 추가: start, | |
| 735 | 추가: Some("space-destination"), | |
| 736 | 추가: vec![], | |
| 737 | 추가: |event| match event { | |
| 738 | 추가: Message::ConflictRequired { challenge_id, .. } => { | |
| 739 | 추가: Some(vec![reply(*challenge_id, ConflictChoice::Skip, apply)]) | |
| 740 | 추가: } | |
| 741 | 추가: _ => None, | |
| 742 | 추가: }, | |
| 743 | 추가: ); | |
| 744 | 추가: assert_eq!( | |
| 745 | 추가: terminal(&events).outcome, | |
| 746 | 추가: Outcome::Completed, | |
| 747 | 추가: "{format}/{apply}: {events:?}" | |
| 748 | 추가: ); | |
| 749 | 추가: assert_eq!(terminal(&events).error, ErrorCode::None); | |
| 750 | 추가: assert_eq!(terminal(&events).publication, Publication::None); | |
| 751 | 추가: assert_eq!(terminal(&events).created_count, 0); | |
| 752 | 추가: assert_eq!(terminal(&events).durability, Durability::NotApplicable); | |
| 753 | 추가: assert_eq!(terminal(&events).cleanup, Cleanup::Complete); | |
| 754 | 추가: assert_eq!(created(&events), 0); | |
| 755 | 추가: let conflicts = if format == "zip" { 2 } else { 1 }; | |
| 756 | 추가: assert_eq!(questions(&events), if apply { 1 } else { conflicts }); | |
| 757 | 추가: assert_eq!( | |
| 758 | 추가: count(&events, |event| matches!( | |
| 759 | 추가: event, | |
| 760 | 추가: Message::ConflictResolved { | |
| 761 | 추가: choice: ConflictChoice::Skip, | |
| 762 | 추가: .. | |
| 763 | 추가: } | |
| 764 | 추가: )), | |
| 765 | 추가: conflicts | |
| 766 | 추가: ); | |
| 767 | 추가: for (name, before) in names.iter().zip(before) { | |
| 768 | 추가: assert_eq!(hash(&s.0.join("output").join(name)), before); | |
| 769 | 추가: } | |
| 770 | 추가: if format == "gzip" { | |
| 771 | 추가: assert_eq!( | |
| 772 | 추가: fs::read(s.0.join("output/chosen.txt")).unwrap(), | |
| 773 | 추가: b"original" | |
| 774 | 추가: ); | |
| 775 | 추가: } | |
| 776 | 추가: assert!( | |
| 777 | 추가: !s.0.join("paused").exists(), | |
| 778 | 추가: "skipped files must not charge destination space" | |
| 779 | 추가: ); | |
| 780 | 추가: } | |
| 781 | 추가: } | |
| 782 | 추가: } | |
| 783 | 추가: #[cfg(target_os = "linux")] | |
| 784 | 추가: #[test] | |
| 785 | 추가: fn destination_space_is_checked_after_overwrite_or_rename_choice() { | |
| 786 | 추가: for choice in [ConflictChoice::Overwrite, ConflictChoice::Rename] { | |
| 787 | 추가: let s = Scratch::new(); | |
| 788 | 추가: fixture(&s, &["a", "b"]); | |
| 789 | 추가: let before = hash(&s.0.join("output/a")); | |
| 790 | 추가: let events = run( | |
| 791 | 추가: &s, | |
| 792 | 추가: request(&s), | |
| 793 | 추가: Some("space-destination"), | |
| 794 | 추가: vec![], | |
| 795 | 추가: |event| match event { | |
| 796 | 추가: Message::ConflictRequired { challenge_id, .. } => { | |
| 797 | 추가: Some(vec![reply(*challenge_id, choice, true)]) | |
| 798 | 추가: } | |
| 799 | 추가: _ => None, | |
| 800 | 추가: }, | |
| 801 | 추가: ); | |
| 802 | 추가: assert_eq!(questions(&events), 1, "{events:?}"); | |
| 803 | 추가: assert_eq!( | |
| 804 | 추가: count(&events, |event| matches!( | |
| 805 | 추가: event, | |
| 806 | 추가: Message::ConflictResolved { .. } | |
| 807 | 추가: )), | |
| 808 | 추가: 1 | |
| 809 | 추가: ); | |
| 810 | 추가: assert_eq!(terminal(&events).error, ErrorCode::DiskFull, "{events:?}"); | |
| 811 | 추가: assert_eq!(terminal(&events).publication, Publication::None); | |
| 812 | 추가: assert_eq!(terminal(&events).created_count, 0); | |
| 813 | 추가: assert_eq!(terminal(&events).cleanup, Cleanup::Complete); | |
| 814 | 추가: assert_eq!(hash(&s.0.join("output/a")), before); | |
| 815 | 추가: assert_eq!(hash(&s.0.join("output/b")), before); | |
| 816 | 추가: assert_eq!(fs::read_dir(s.0.join("output")).unwrap().count(), 2); | |
| 817 | 추가: assert!(s.0.join("paused").exists()); | |
| 818 | 추가: } | |
| 819 | 추가: } | |
| 820 | 추가: #[cfg(target_os = "linux")] | |
| 821 | 추가: #[test] | |
| 822 | 추가: fn skipped_files_do_not_charge_space_for_remaining_publication() { | |
| 823 | 추가: for choice in [ | |
| 824 | 추가: Some(ConflictChoice::Overwrite), | |
| 825 | 추가: Some(ConflictChoice::Rename), | |
| 826 | 추가: None, | |
| 827 | 추가: ] { | |
| 828 | 추가: let s = Scratch::new(); | |
| 829 | 추가: fixture(&s, &["a", "b", "c"]); | |
| 830 | 추가: assert!(PAYLOAD.len() <= 64 && PAYLOAD.len() * 3 > 64); | |
| 831 | 추가: if choice.is_none() { | |
| 832 | 추가: fs::remove_file(s.0.join("output/c")).unwrap(); | |
| 833 | 추가: } | |
| 834 | 추가: let events = run( | |
| 835 | 추가: &s, | |
| 836 | 추가: request(&s), | |
| 837 | 추가: Some("space-one-output"), | |
| 838 | 추가: vec![], | |
| 839 | 추가: |event| match event { | |
| 840 | 추가: Message::ConflictRequired { | |
| 841 | 추가: challenge_id, | |
| 842 | 추가: entry_id, | |
| 843 | 추가: .. | |
| 844 | 추가: } => { | |
| 845 | 추가: let choice = if *entry_id < 2 { | |
| 846 | 추가: ConflictChoice::Skip | |
| 847 | 추가: } else { | |
| 848 | 추가: choice.unwrap() | |
| 849 | 추가: }; | |
| 850 | 추가: Some(vec![reply(*challenge_id, choice, false)]) | |
| 851 | 추가: } | |
| 852 | 추가: _ => None, | |
| 853 | 추가: }, | |
| 854 | 추가: ); | |
| 855 | 추가: assert_eq!( | |
| 856 | 추가: terminal(&events).outcome, | |
| 857 | 추가: Outcome::Completed, | |
| 858 | 추가: "{choice:?}: {events:?}" | |
| 859 | 추가: ); | |
| 860 | 추가: assert_eq!(terminal(&events).publication, Publication::Complete); | |
| 861 | 추가: assert_eq!(terminal(&events).created_count, 1); | |
| 862 | 추가: assert_eq!(created(&events), 1); | |
| 863 | 추가: assert_eq!(questions(&events), if choice.is_some() { 3 } else { 2 }); | |
| 864 | 추가: assert_eq!(fs::read(s.0.join("output/a")).unwrap(), b"original"); | |
| 865 | 추가: assert_eq!(fs::read(s.0.join("output/b")).unwrap(), b"original"); | |
| 866 | 추가: let output = if choice == Some(ConflictChoice::Rename) { | |
| 867 | 추가: "c (1)" | |
| 868 | 추가: } else { | |
| 869 | 추가: "c" | |
| 870 | 추가: }; | |
| 871 | 추가: assert_eq!(fs::read(s.0.join("output").join(output)).unwrap(), PAYLOAD); | |
| 872 | 추가: if choice == Some(ConflictChoice::Rename) { | |
| 873 | 추가: assert_eq!(fs::read(s.0.join("output/c")).unwrap(), b"original"); | |
| 874 | 추가: } | |
| 875 | 추가: assert!(s.0.join("paused").exists()); | |
| 876 | 추가: } | |
| 877 | 추가: } | |
| 878 | 추가: #[cfg(target_os = "linux")] | |
| 879 | 추가: #[test] | |
| 880 | 추가: fn insufficient_destination_space_does_not_prevent_cancellation() { | |
| 881 | 추가: let s = Scratch::new(); | |
| 882 | 추가: fixture(&s, &["a"]); | |
| 883 | 추가: let events = run( | |
| 884 | 추가: &s, | |
| 885 | 추가: request(&s), | |
| 886 | 추가: Some("space-destination"), | |
| 887 | 추가: vec![], | |
| 888 | 추가: |event| matches!(event, Message::ConflictRequired { .. }).then(|| vec![Message::Cancel]), | |
| 889 | 추가: ); | |
| 890 | 추가: assert_eq!(questions(&events), 1, "{events:?}"); | |
| 891 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Cancelled, "{events:?}"); | |
| 892 | 추가: assert_eq!(terminal(&events).publication, Publication::None); | |
| 893 | 추가: assert_eq!(fs::read(s.0.join("output/a")).unwrap(), b"original"); | |
| 894 | 추가: } | |
| 895 | 추가: #[cfg(target_os = "linux")] | |
| 896 | 추가: #[test] | |
| 897 | 추가: fn interactive_staging_space_and_integrity_checks_remain_before_questions() { | |
| 898 | 추가: for corrupt in [false, true] { | |
| 899 | 추가: let s = Scratch::new(); | |
| 900 | 추가: fixture(&s, &["a"]); | |
| 901 | 추가: if corrupt { | |
| 902 | 추가: let mut bytes = fs::read(s.0.join("input")).unwrap(); | |
| 903 | 추가: let at = bytes | |
| 904 | 추가: .windows(PAYLOAD.len()) | |
| 905 | 추가: .position(|bytes| bytes == PAYLOAD) | |
| 906 | 추가: .unwrap(); | |
| 907 | 추가: bytes[at] ^= 1; | |
| 908 | 추가: fs::write(s.0.join("input"), bytes).unwrap(); | |
| 909 | 추가: } | |
| 910 | 추가: let fault = if corrupt { | |
| 911 | 추가: "space-destination" | |
| 912 | 추가: } else { | |
| 913 | 추가: "space-stage" | |
| 914 | 추가: }; | |
| 915 | 추가: let events = run(&s, request(&s), Some(fault), vec![], |_| None); | |
| 916 | 추가: assert_eq!( | |
| 917 | 추가: terminal(&events).error, | |
| 918 | 추가: if corrupt { | |
| 919 | 추가: ErrorCode::Integrity | |
| 920 | 추가: } else { | |
| 921 | 추가: ErrorCode::DiskFull | |
| 922 | 추가: }, | |
| 923 | 추가: "{events:?}" | |
| 924 | 추가: ); | |
| 925 | 추가: assert_eq!(questions(&events), 0); | |
| 926 | 추가: assert_eq!(created(&events), 0); | |
| 927 | 추가: assert_eq!(terminal(&events).publication, Publication::None); | |
| 928 | 추가: assert_eq!(fs::read(s.0.join("output/a")).unwrap(), b"original"); | |
| 929 | 추가: } | |
| 930 | 추가: } |
| @@ -116,11 +116,16 @@ int fstatvfs(int fd, struct statvfs *value) { | ||
| 116 | 116 | if (fstat(fd, &st)) return -1; |
| 117 | 117 | int affected = !strcmp(fault, "space-error") || !strcmp(fault, "space-combined") |
| 118 | 118 | || (!strcmp(fault, "space-stage") && S_ISREG(st.st_mode)) |
| 119 | 삭제: || (!strcmp(fault, "space-destination") && S_ISDIR(st.st_mode)); | |
| 119 | 추가: || ((!strcmp(fault, "space-destination") || !strcmp(fault, "space-one-output")) && S_ISDIR(st.st_mode)); | |
| 120 | 120 | if (!affected) return result; |
| 121 | 121 | int marker = real_openat(AT_FDCWD, getenv("ZIPELO_TEST_MARKER"), O_CREAT | O_WRONLY, 0600); |
| 122 | 122 | if (marker >= 0) close(marker); |
| 123 | 123 | if (!strcmp(fault, "space-error")) { errno = EIO; return -1; } |
| 124 | 추가: if (!strcmp(fault, "space-one-output")) { | |
| 125 | 추가: value->f_frsize = 1; | |
| 126 | 추가: value->f_bavail = 64; | |
| 127 | 추가: return 0; | |
| 128 | 추가: } | |
| 124 | 129 | value->f_bavail = !strcmp(fault, "space-combined") ? (1536 * 1024) / value->f_frsize : 0; |
| 125 | 130 | return 0; |
| 126 | 131 | } |