7z 생성 공용 타입과 코덱을 추가함
- 작성자
- 시로사키 하나
- 작성 시각
- 커밋
ede56f33beb27bbdc3cb69b32a5ff14509f7a823- 부모
- 03ca5c5
변경된 파일 8개
+500-10| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | # 7z 생성 설계와 작업자 계약안 |
| 2 | 2 | |
| 3 | 삭제: 상태: backend 제안, frontend 계약 동의 대기. 2026-11-14의 main c61cd2f를 확인한 설계 문서이며 구현 및 호환 시험 통과를 뜻하지 않는다. [PLANS 8.9](PLANS.md#89-7z-만들기)와 [8.13](PLANS.md#813-진행과-완료-판단)을 따른다. 이 PR은 이 문서 한 개만 추가하며 공용 타입, contract.json, 의존성과 화면은 아직 바꾸지 않는다. | |
| 3 | 추가: 상태: frontend 계약 동의와 독립 설계 리뷰 완료. [앱 계약 승인](https://github.com/Team-LJY/zipelo/pull/127#pullrequestreview-5903269732)과 [설계 리뷰](https://github.com/Team-LJY/zipelo/pull/127#pullrequestreview-5903282961)는 03ca5c5 기준이다. 공용 타입, codec과 contract.json을 반영했으며 실제 작성기, 의존성 기능 변경과 화면 연동은 아직 없다. 현재 모든 CreateSevenZip 요청은 Accepted(encryption=false) 뒤 자원 질문이나 파일 접근 없이 UnsupportedFeature로 종료한다. 아래 작성기 설계와 수용 시험은 구현/호환 통과를 뜻하지 않는다. [PLANS 8.9](PLANS.md#89-7z-만들기)와 [8.13](PLANS.md#813-진행과-완료-판단)을 따른다. | |
| 4 | 4 | |
| 5 | 5 | ## 1. 이번 지원 범위 |
| 6 | 6 | |
| @@ -32,7 +32,7 @@ | ||
| 32 | 32 | |
| 33 | 33 | ## 4. 작업자와 앱 계약안 |
| 34 | 34 | |
| 35 | 삭제: 현재 기준은 과거 C# 문서가 아닌 [작업자 README](../experiments/rust-archive-worker/README.md), protocol.rs, wire.rs와 contract.json이다. 아래는 미합의 확장안이며 구현된 계약으로 표시하지 않는다. | |
| 35 | 추가: 현재 기준은 과거 C# 문서가 아닌 [작업자 README](../experiments/rust-archive-worker/README.md), protocol.rs, wire.rs와 contract.json이다. 아래 확장 계약은 합의되었고 공용 타입과 바이트 인코딩은 반영했다. 실제 작성기와 앱 연동의 구현 상태는 위 상태 및 contract.json의 seven_zip_create.status로 구분한다. | |
| 36 | 36 | |
| 37 | 37 | ### 요청과 바이트 순서 |
| 38 | 38 | |
| @@ -75,6 +75,7 @@ | ||
| 75 | 75 | 아래는 아직 수행하지 않은 검증 계획이다. 시험 코드는 루트 tests/에만 두며 일회성 자료, 도구, 캐시와 로그는 tests/work/sevenzip-create 한 곳에 모은다. TMPDIR과 CARGO_TARGET_DIR을 그 하위에 명시하고 사본 안에 작업 폴더나 빌드 캐시를 다시 만들지 않는다. PR 병합/종료 뒤 담당자가 정리한다. |
| 76 | 76 | |
| 77 | 77 | - 일반 파일, 압축되는/난수 내용, 한글 및 여러 단계 경로, 혼합 파일/폴더, 빈 파일, 빈 폴더, 빈 폴더만 있는 묶음과 여러 최상위 원본을 만든다. Zipelo 목록/해제와 독립 7-Zip의 테스트/목록/해제를 각각 실행해 상대 경로, 항목 종류, 파일 크기와 SHA256을 원본 manifest와 대조한다. 압축 아카이브 바이트 자체의 일치는 요구하지 않는다. |
| 78 | 추가: - 독립 설계 리뷰의 후속 기준으로 MainStreamsInfo/kEnd 계층, 32바이트 기준 NextHeaderOffset, 가변 UINT64와 고정 REAL_UINT64 구분을 확인한다. EmptyFile 비트 수는 전체 파일 수가 아닌 empty stream 수이며 혼합 빈 항목 7/8/9개와 정수 경계 127/128, 16383/16384를 포함한다. | |
| 78 | 79 | - 독립 도구의 상세 목록으로 LZMA2, non-solid와 비암호화를 확인한다. 헤더/스트림 CRC와 작은 경계, 64 KiB 경계, 4 GiB 크기/오프셋 인코딩 및 비압축 헤더 상한을 시험한다. 큰 수치는 축소 상한/메타데이터 표본 검증과 실제 대용량 실행을 구분한다. |
| 79 | 80 | - 자원 기본/승인 경계, 거부와 취소, 파일/폴더 수 합산, 메타데이터 및 산술 오버플로, 위험 경로, 링크/특수 파일, 원본/부모 교체, 목적지 새 파일 출현과 기존 파일 보존을 검증한다. 파일 크기와 무관하게 큰 배열이 생기지 않는지 확인한다. |
| 80 | 81 | - 캡처/압축/finish/헤더 패치/게시 직전 취소, 부모 종료, 임시/목적지 디스크 부족, write/seek/sync/close/게시/정리 실패를 주입한다. 게시 전에는 완성 파일이 없어야 하며 실패/취소를 Completed로 표시하지 않아야 한다. 게시 뒤 실패와 강제 종료에서는 실제 게시 및 정리 상태를 대조한다. |
| @@ -83,7 +84,7 @@ | ||
| 83 | 84 | |
| 84 | 85 | ## 8. 합의와 담당 인계 |
| 85 | 86 | |
| 86 | 삭제: - 하나는 이 계약안과 backend 작성기, 공용 타입/codec 및 작업자 회귀를 담당한다. 히나타의 계약 동의 또는 수정 의견이 확인되기 전에는 타입과 제품 구현을 시작하지 않는다. | |
| 87 | 추가: - 하나는 이 계약과 backend 작성기, 공용 타입/codec 및 작업자 회귀를 담당한다. 히나타의 계약 동의와 카논의 설계 리뷰가 확인되어 공용 타입 인계 단계에 착수했다. 실제 작성기는 후속 구현이다. | |
| 87 | 88 | - 계약 동의 뒤 공용 타입 반영 커밋을 히나타에게 전달한다. 히나타는 기존 생성 화면의 ZIP/7z 형식 선택, .7z 기본 저장 형식, 암호/방식 선택 제한, 새 ActionKind 변환과 수신 검증을 담당한다. 화면이 바뀌는 구현 PR에 --ui-scenario 목록/시험과 docs/ui-scenario-guide.md를 함께 갱신한다. 별도 디자인 변경이나 애니메이션을 추가하지 않는다. |
| 88 | 삭제: - 카논에게 설계와 실패 경계 리뷰, 구현 후 독립 7-Zip 호환 검증 및 재리뷰를 요청한다. 도구 버전/옵션, 원본과 해제 manifest 및 플랫폼별 실행 범위를 남긴다. 도구를 제품에 번들하지 않는다. | |
| 89 | 추가: - 카논의 설계와 실패 경계 리뷰는 완료되었으며 구현 후 독립 7-Zip 호환 검증 및 재리뷰는 별도 요청한다. 도구 버전/옵션, 원본과 해제 manifest 및 플랫폼별 실행 범위를 남긴다. 도구를 제품에 번들하지 않는다. | |
| 89 | 90 | - 설계 문서의 정적 검토와 링크/공백 검사는 제품 빌드나 호환 검증이 아니다. 이번 PR은 UI 변경 없음이며 구현 시작 조건과 아직 수행하지 않은 시험을 명시한 초안으로 유지한다. |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | # Rust archive worker |
| 2 | 2 | |
| 3 | 삭제: 별도 프로세스의 stdin/stdout으로 revision 3 요청을 처리합니다. 제품 앱이 공유 codec으로 연결하며 프로세스 분리는 OS sandbox를 뜻하지 않습니다. 암호 기능은 capability=true이며 ZipCrypto 해제, WinZip AES-256 AE-1/AE-2 해제와 AE-2 생성을 지원합니다. | |
| 3 | 추가: 별도 프로세스의 stdin/stdout으로 revision 3 요청을 처리합니다. 제품 앱이 공유 codec으로 연결하며 프로세스 분리는 OS sandbox를 뜻하지 않습니다. 기존 작업의 암호 기능은 capability=true이며 ZipCrypto 해제, WinZip AES-256 AE-1/AE-2 해제와 AE-2 생성을 지원합니다. | |
| 4 | 4 | |
| 5 | 5 | - ZIP32/ZIP64 Store/Deflate 목록과 해제, ZIP32/ZIP64 생성, 기본 TAR/USTAR, GZ, TAR.GZ, TAR.BZ2, TAR.XZ, 비암호화 7z 해제를 지원합니다. GZ 연결 멤버는 하나의 논리 스트림으로 합칩니다. 다중 볼륨, UTF-8로 해석할 수 없는 ZIP 이름, PAX/GNU 확장과 특수 항목 해제는 미지원입니다. |
| 6 | 6 | - ZIP 이름: UTF-8 플래그(비트 11)가 있으면 이름이 UTF-8이어야 하며 아니면 Integrity입니다. 플래그가 없으면 CRC가 원래 이름과 맞는 Info-ZIP Unicode Path 확장 필드(0x7075, 버전 1)를 우선 쓰고, 다음으로 UTF-8로 유효한 이름 바이트를 그대로 씁니다(Linux/macOS 도구의 기본 동작). CRC가 다르거나 버전이 다른 확장 필드는 무시합니다. 그 밖의 CP437/CP949 등 레거시 이름은 코드 페이지를 추측하지 않고 UnsupportedFeature로 거부합니다. 어느 경로로 얻은 이름이든 같은 경로 안전성 검사와 충돌 검사를 거칩니다. |
| @@ -69,6 +69,16 @@ Python 표준 bz2, lzma와 tarfile로 독립 생성 및 해제한 결과의 SHA2 | ||
| 69 | 69 | |
| 70 | 70 | 7z의 Copy/LZMA/LZMA2 입력과 solid 출력은 고정 버퍼와 임시 파일로 처리합니다. 모든 폴더와 하위 스트림의 CRC와 크기 검증이 끝난 뒤 기존 게시 경로를 사용합니다. ZIP 생성의 압축 및 AES 처리도 64 KiB 버퍼를 사용하며 여유 공간 사전 검사와 실제 쓰기의 DiskFull 구분을 적용합니다. 공간 예약을 보장하지 않으므로 다른 프로세스와의 경쟁으로 쓰기가 실패할 수 있습니다. |
| 71 | 71 | |
| 72 | 추가: ## 7z 생성 계약과 구현 상태 | |
| 73 | 추가: | |
| 74 | 추가: [합의된 설계](../../docs/sevenzip-create-design.md)에 따라 공용 타입과 codec을 추가했습니다. 실제 7z 작성기와 앱 형식 선택은 아직 미구현입니다. 현재 CreateSevenZip 요청은 Accepted(encryption=false) 뒤 UnsupportedFeature로 종료하며 원본, 목적지와 임시 파일을 열거나 자원/암호/충돌 질문을 보내지 않습니다. 정상 옵션도 이 경로로 명시적으로 실패하며 ZIP으로 우회하지 않습니다. | |
| 75 | 추가: | |
| 76 | 추가: - Action과 ActionKind의 CreateSevenZip tag는 4입니다. 필드 순서는 sources:Vec<Source>, output_file:NativePath, method:SevenZipMethod, solid:bool, encryption:Encryption입니다. Source는 기존 path와 archive_name 순서이며 SevenZipMethod는 Lzma2=0만 정의합니다. ZIP Method의 Store=0, Deflate=1과 기존 모든 tag/프레임은 유지합니다. | |
| 77 | 추가: - Start 또는 StartGuarded(interactive=false)에 허용합니다. StartInteractive와 guarded interactive=true는 양방향 codec에서 거부합니다. 확대 ceiling도 sources/경로 Vec의 32,768개, String의 32,768 UTF-8 바이트와 1 MiB 프레임 전송 상한을 늘리지 않습니다. ResourceRequired.action도 새 tag 4를 전송할 수 있지만 현재 미구현 작성기는 질문 전에 실패합니다. | |
| 78 | 추가: - 구현 목표는 LZMA2, non-solid, 본문/헤더 암호화 없음입니다. solid=true와 Aes256은 구조상 유효하지만 Supported로 간주하지 않으며 질문/출력 전 UnsupportedFeature입니다. 알 수 없는 enum/bool과 잔여 본문은 codec 오류입니다. 구버전이나 다른 형식으로 자동 재시도하지 않습니다. | |
| 79 | 추가: - 향후 작성기는 ZIP과 같은 원본 계획, 취소, 자원 승인, 비공개 스테이징과 배타적 게시 경로를 재사용합니다. 기존 목적지를 덮어쓰지 않으며 성공에는 최종 아카이브 하나의 Output Created와 Complete/created_count=1이 필요합니다. 앱의 확정 조건은 기존 Terminal, 양쪽 EOF와 자식 회수 그대로입니다. 실제 게시 후 오류와 정리 실패를 성공/무출력으로 바꾸지 않습니다. | |
| 80 | 추가: - tests/rust-archive-worker/seven_zip_create.rs는 요청 바이트, Unix/Windows 경로, tag/옵션/전송 경계와 현재 미지원 동작의 무질문/무게시 및 기존 파일 보존을 검증합니다. 실제 인코딩, 독립 도구 호환과 OS 화면 시험의 근거는 아닙니다. 의존성/encoder 기능은 이 인계에서 바꾸지 않습니다. | |
| 81 | 추가: | |
| 72 | 82 | ## ZIP 생성 입력 |
| 73 | 83 | |
| 74 | 84 | 원본에 일반 파일과 폴더를 함께 지정할 수 있습니다. 각 archive_name을 최상위 이름으로 쓰고 폴더 안의 상대 경로와 빈 폴더를 보존합니다. 재귀 수집된 파일과 폴더 모두 항목 수 한도에 포함하며 파일 크기 합계에는 기존 16 GiB 기본 한도를 적용합니다. 이름 충돌과 한도는 암호 요청 전에 검사합니다. |
| @@ -26,7 +26,7 @@ | ||
| 26 | 26 | "archive_names": "Separate validated UTF-8 relative names; entry IDs are opaque ordinal u32, not paths." |
| 27 | 27 | }, |
| 28 | 28 | "commands": { |
| 29 | 삭제: "Start": "Exactly once: List{archive}, Extract{archive,destination,selection:All|EntryIds{ids:[u32]},list_id:optional<ListId>,gzip_output_name:optional<UTF8>}, CreateZip{sources:[source_path,archive_name],output_file,method:Store|Deflate,encryption:None|Aes256}. App supplies job_id; caller can lower worker hard limits. Extract destination is always an absolute output directory. EntryIds requires list_id; All may supply list_id to bind extraction to a displayed list.", | |
| 29 | 추가: "Start": "Exactly once: List{archive}, Extract{archive,destination,selection:All|EntryIds{ids:[u32]},list_id:optional<ListId>,gzip_output_name:optional<UTF8>}, CreateZip{sources:[source_path,archive_name],output_file,method:Store|Deflate,encryption:None|Aes256}. App supplies job_id; caller can lower worker hard limits. Extract destination is always an absolute output directory. EntryIds requires list_id; All may supply list_id to bind extraction to a displayed list. CreateSevenZip{sources:[Source{path:NativePath,archive_name:UTF8}],output_file:NativePath,method:SevenZipMethod,solid:bool,encryption:Encryption} appends action tag 4. Shared types and codec are implemented; the pending writer returns UnsupportedFeature after Accepted before file access or questions.", | |
| 30 | 30 | "Password": "Matching outstanding challenge_id:u64 and max1024 UTF-8 bytes; never log, Debug, echo or persist secrets.", |
| 31 | 31 | "Cancel": "Matching header job_id and empty body; command header sequence identifies the request. See CancelAck. Request acceptance is separate from final outcome. EOF alone is not successful cancellation.", |
| 32 | 32 | "StartInteractive": "Kind 4, body identical to Start with action restricted to Extract. Exactly one initial Start or StartInteractive. Invalid non-Extract action is rejected by the shared encoder and decoder. Opt in to interactive regular-file conflicts; never retry through legacy Start or an older worker automatically. Worker runtime supports the agreed choices; client activation and native UI integration are verified separately.", |
| @@ -35,7 +35,7 @@ | ||
| 35 | 35 | "ResourceReply": "Kind 7: challenge_id:u64,scope:ResourceScope,allow:bool. Frame job_id and exact outstanding challenge_id/scope must match once. Reject premature, stale, duplicate and cross-kind replies as Protocol. False cancels the job without further processing." |
| 36 | 36 | }, |
| 37 | 37 | "events": { |
| 38 | 삭제: "Accepted": "Action and capabilities; encryption capability is true for implemented ZipCrypto extraction and WinZip AES-256 extraction/creation.", | |
| 38 | 추가: "Accepted": "Action and capabilities; encryption capability is true for implemented ZipCrypto extraction and WinZip AES-256 extraction/creation. CreateSevenZip explicitly reports encryption=false; existing action capabilities are unchanged.", | |
| 39 | 39 | "Entry": "entry_id, name, kind File|Directory|Link|Other, declared sizes, encrypted; ordinal u32 IDs belong to this List job only until its ListEnd token and Completed Terminal are confirmed. Metadata only, no CRC success claim.", |
| 40 | 40 | "ListEnd": "entry_count:u32 and list_id:ListId for a complete listing. Entry IDs are deterministic zero-based ordinals in archive traversal order. App associates this token with this job entries only after Completed Terminal, both stream EOFs and successful child wait/exit.", |
| 41 | 41 | "PasswordRequired": "challenge_id, attempt and purpose Decrypt|Encrypt; no secret diagnostics.", |
| @@ -229,7 +229,7 @@ | ||
| 229 | 229 | "guarded_resources": { |
| 230 | 230 | "status": "worker-and-client-implemented; native Windows/Wayland verification pending", |
| 231 | 231 | "agreement": "Frontend flow agreement 6fe5a494-7d5a-4bda-a7d3-831fb43e9238 and manager policy b3a743d2-10de-495c-8fdb-ecf2a5f3b453. Frame version 1, revision 3 messages and enum tags remain unchanged; this is an explicit opt-in extension.", |
| 232 | 삭제: "admission": "After Accepted, request the output and/or entries scopes that ceiling increases above Start limits before capturing input or planning sources. Usage estimates and actuals are unknown at this point; report current staging-volume free space. The caller must show the requested ceilings and unknown values, not invent estimates. An earlier confirmation is needed because input capture itself can exceed 300 seconds. Each granted scope is confined to this job.", | |
| 232 | 추가: "admission": "After Accepted, request the output and/or entries scopes that ceiling increases above Start limits before capturing input or planning sources. Usage estimates and actuals are unknown at this point; report current staging-volume free space. The caller must show the requested ceilings and unknown values, not invent estimates. An earlier confirmation is needed because input capture itself can exceed 300 seconds. Each granted scope is confined to this job. Exception during CreateSevenZip writer development: safe UnsupportedFeature refusal precedes all resource questions and temporary-file access; this is not an implementation of creation.", | |
| 233 | 233 | "ratio": "Request ratio scope separately when expanded bytes are at least 256 MiB and strictly exceed compressed bytes times 1000. Check ZIP members and aggregate payload totals, 7z solid folders and totals, and complete compressed TAR/GZip streams. Use u128 arithmetic; unknown compressed length does not become zero. No ratio warning for legacy requests.", |
| 234 | 234 | "accounting": "Monitor declared catalog sums and counts, real decoded bytes, per-stream ratios and source-plan sums. Decoders must match verified declared lengths before publication. For compressed TAR/GZip the expanded stream includes headers/padding. ZIP creation ceiling counts source logical bytes; ZIP/container/encryption overhead is separately space-checked.", |
| 235 | 235 | "disk": "Continue staging/destination volume preflight and per-chunk space checks after approval. available_bytes is advisory free space on the current observation storage volume, not a reservation or all-volume total. Unknown storage is None. Preserve DiskFull, partial publication, durability and cleanup semantics.", |
| @@ -239,5 +239,32 @@ | ||
| 239 | 239 | "metadata": "Only after a valid ResourceReply(allow=true) for this job, select 64 MiB MetadataBudget and 262144 nodes, including ZIP/TAR/7z parsing, decoded 7z headers, XZ index/block bounds, member/path validation, implicit output parents and source planning. Legacy Start/StartInteractive, unapproved guarded jobs and slice APIs keep 8 MiB and 32768 nodes. Merely requesting expanded ceilings does not grant a larger budget. Names and source paths still consume checked byte budgets and implicit parents consume nodes, so long/deep paths can hit the metadata cap before 200000 entries. Approved source-path/pending-name copies consume bytes without duplicating their entry node. Expanded metadata jobs do not retain a universal 64 MiB RSS target.", |
| 240 | 240 | "client": "Normal app jobs use StartGuarded with the existing 16 GiB and 10000-entry limits. Known selection/file estimates request expanded ceilings before processing. After a Limit result, offer an explicit expanded retry only after Terminal, both EOFs and child reap, with Publication::None, zero created/partial counts and complete cleanup. Retry uses a new job ID and requires fresh approval; existing or uncertain output instead shows the saved location and detailed result. App output records, including implicit parent directories, grow to 262144 nodes after any valid resource approval. Catalog entries grow to 200000 only for jobs granted the entries scope. Unapproved output records and catalogs without an entries grant retain their existing 100000 caps. Resource approval, ratio, retry and partial-output UI scenarios, tests and docs/ui-scenario-guide.md are implemented. Native Windows/Wayland verification remains separate.", |
| 241 | 241 | "tests": "Use numeric 16/64 GiB and 10000/200000 policy boundaries, scaled worker limits, a compressed 257 MiB zero stream, and a virtual clock for the 60-second stall. Include client approval/retry tests in tests/rust-app-ui/guarded.rs and real-worker flows in tests/rust-app-real-worker/guarded_flows.rs. Do not write 64 GiB in tests." |
| 242 | 추가: }, | |
| 243 | 추가: "action_tags": { | |
| 244 | 추가: "List": 0, | |
| 245 | 추가: "Extract": 1, | |
| 246 | 추가: "CreateZip": 2, | |
| 247 | 추가: "Preview": 3, | |
| 248 | 추가: "CreateSevenZip": 4 | |
| 249 | 추가: }, | |
| 250 | 추가: "seven_zip_method_tags": { | |
| 251 | 추가: "Lzma2": 0 | |
| 252 | 추가: }, | |
| 253 | 추가: "seven_zip_create": { | |
| 254 | 추가: "status": "shared-types-codec-and-safe-refusal-implemented; writer-and-app-integration-pending", | |
| 255 | 추가: "agreement": { | |
| 256 | 추가: "frontend_message_id": "770f1004-0a2b-4fc6-aafd-7f705c8f6c9e", | |
| 257 | 추가: "frontend_review": "https://github.com/Team-LJY/zipelo/pull/127#pullrequestreview-5903269732", | |
| 258 | 추가: "design_review": "https://github.com/Team-LJY/zipelo/pull/127#pullrequestreview-5903282961" | |
| 259 | 추가: }, | |
| 260 | 추가: "request": "Append Action::CreateSevenZip and ActionKind::CreateSevenZip=4. Field order: sources:Vec<Source>,output_file:NativePath,method:SevenZipMethod(u8 Lzma2=0),solid:bool,encryption:Encryption(u8 None=0,Aes256=1). Source remains path:NativePath,archive_name:UTF8. Preserve ZIP Method Store=0,Deflate=1, all previous tags, frame version and fields.", | |
| 261 | 추가: "admission": "Start and StartGuarded(interactive=false) are valid. Shared encoder and decoder reject StartInteractive and guarded interactive=true. Sources, native path vectors and strings retain the 32768 item/UTF8-byte bounds and the 1 MiB frame bound even with an expanded ceiling. No automatic fallback to ZIP, Start or an older worker.", | |
| 262 | 추가: "options": "Target support is single-file .7z with LZMA2, non-solid and no body/header encryption. Structurally valid solid=true or Aes256 requests must fail UnsupportedFeature after Accepted, before source enumeration, resource/password/conflict questions or outputs. Unknown enum/bool tags and trailing fields are protocol errors.", | |
| 263 | 추가: "implementation_boundary": "Until the writer is implemented, every CreateSevenZip request, including Lzma2/solid=false/None, takes this same safe UnsupportedFeature path before resource admission and temporary-file creation. Accepted is not a creation capability or success claim. Do not release the format selector as a working feature yet.", | |
| 264 | 추가: "events": "Accepted.action and future ResourceRequired.action use tag 4; Accepted.encryption=false. Future writer reuses Progress Scan/Read/Write/Verify/Commit and guarded resource approval. Unknown totals remain None. No PasswordRequired or ConflictRequired. Exactly one normal Output Created for the published archive, entry_id=None and relative_name=actual destination leaf; not one Output per archive member.", | |
| 265 | 추가: "publication": "Future writer uses ZIP source planning, consistency checks, private file-backed staging and exclusive publication (replace=None). Existing or newly appeared destination returns Conflict without overwrite. Completed requires publication Complete and created_count=1. Prepublication failure/cancel has publication None and zero created/retained counts unless owned temporary cleanup actually failed. Preserve actual postpublication errors, durability, cleanup and uncertain state.", | |
| 266 | 추가: "lifecycle": "Reuse Cancel/CancelAck/Terminal and matching job/challenge/sequence validation. CancelAck is not completion; app requires Terminal, both stream EOFs and owned child wait. No synthetic rollback after publication.", | |
| 267 | 추가: "dependencies": "No dependency or feature change in the common-types handoff. lzma-rust2 encoder selection, notices, current advisory applicability and actual compatibility require writer implementation and validation.", | |
| 268 | 추가: "design": "docs/sevenzip-create-design.md" | |
| 242 | 269 | } |
| 243 | 270 | } |
| @@ -201,6 +201,10 @@ pub enum Method { | ||
| 201 | 201 | Deflate, |
| 202 | 202 | } |
| 203 | 203 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
| 204 | 추가: pub enum SevenZipMethod { | |
| 205 | 추가: Lzma2, | |
| 206 | 추가: } | |
| 207 | 추가: #[derive(Clone, Copy, Debug, PartialEq, Eq)] | |
| 204 | 208 | pub enum Encryption { |
| 205 | 209 | None, |
| 206 | 210 | Aes256, |
| @@ -233,6 +237,13 @@ pub enum Action { | ||
| 233 | 237 | entry_id: u32, |
| 234 | 238 | list_id: ListId, |
| 235 | 239 | }, |
| 240 | 추가: CreateSevenZip { | |
| 241 | 추가: sources: Vec<Source>, | |
| 242 | 추가: output_file: NativePath, | |
| 243 | 추가: method: SevenZipMethod, | |
| 244 | 추가: solid: bool, | |
| 245 | 추가: encryption: Encryption, | |
| 246 | 추가: }, | |
| 236 | 247 | } |
| 237 | 248 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
| 238 | 249 | pub enum ActionKind { |
| @@ -240,6 +251,7 @@ pub enum ActionKind { | ||
| 240 | 251 | Extract, |
| 241 | 252 | CreateZip, |
| 242 | 253 | Preview, |
| 254 | 추가: CreateSevenZip, | |
| 243 | 255 | } |
| 244 | 256 | impl Action { |
| 245 | 257 | pub fn kind(&self) -> ActionKind { |
| @@ -248,6 +260,7 @@ impl Action { | ||
| 248 | 260 | Self::Extract { .. } => ActionKind::Extract, |
| 249 | 261 | Self::CreateZip { .. } => ActionKind::CreateZip, |
| 250 | 262 | Self::Preview { .. } => ActionKind::Preview, |
| 263 | 추가: Self::CreateSevenZip { .. } => ActionKind::CreateSevenZip, | |
| 251 | 264 | } |
| 252 | 265 | } |
| 253 | 266 | } |
| @@ -545,9 +545,13 @@ impl<W: Write> Job<W> { | ||
| 545 | 545 | let limits = self.budget.as_ref().map_or(start.limits, |b| b.ceiling); |
| 546 | 546 | self.event(Message::Accepted { |
| 547 | 547 | action: start.action.kind(), |
| 548 | 삭제: encryption: true, | |
| 548 | 추가: encryption: !matches!(start.action, Action::CreateSevenZip { .. }), | |
| 549 | 549 | })?; |
| 550 | 550 | self.check()?; |
| 551 | 추가: // 작성기 구현 전에는 자원 승인과 파일 접근을 시작하지 않음. | |
| 552 | 추가: if matches!(start.action, Action::CreateSevenZip { .. }) { | |
| 553 | 추가: return Err(ErrorCode::UnsupportedFeature); | |
| 554 | 추가: } | |
| 551 | 555 | if let Some(budget) = &self.budget { |
| 552 | 556 | let scope = ResourceScope { |
| 553 | 557 | output: budget.ceiling.output > budget.soft.output, |
| @@ -921,6 +925,7 @@ impl<W: Write> Job<W> { | ||
| 921 | 925 | self.output_reader(&root, &name, &mut data, length, None, true, None)?; |
| 922 | 926 | self.terminal.publication = Publication::Complete; |
| 923 | 927 | } |
| 928 | 추가: Action::CreateSevenZip { .. } => return Err(ErrorCode::UnsupportedFeature), | |
| 924 | 929 | } |
| 925 | 930 | self.cutoff()?; |
| 926 | 931 | Ok(()) |
| @@ -137,8 +137,9 @@ macro_rules! enumeration { ($t:ident {$($v:ident=$n:expr),*$(,)?}) => { impl Wir | ||
| 137 | 137 | } }; } |
| 138 | 138 | enumeration!(Format{Zip=0,Tar=1,Gzip=2,TarGzip=3,SevenZip=4}); |
| 139 | 139 | enumeration!(Method{Store=0,Deflate=1}); |
| 140 | 추가: enumeration!(SevenZipMethod{Lzma2=0}); | |
| 140 | 141 | enumeration!(Encryption{None=0,Aes256=1}); |
| 141 | 삭제: enumeration!(ActionKind{List=0,Extract=1,CreateZip=2,Preview=3}); | |
| 142 | 추가: enumeration!(ActionKind{List=0,Extract=1,CreateZip=2,Preview=3,CreateSevenZip=4}); | |
| 142 | 143 | enumeration!(PreviewFormat{Utf8Text=0,Rgba8=1}); |
| 143 | 144 | enumeration!(EntryKind{File=0,Directory=1,Link=2,Other=3}); |
| 144 | 145 | enumeration!(Stage{Scan=0,Read=1,Decode=2,Write=3,Verify=4,Commit=5}); |
| @@ -385,6 +386,20 @@ impl Wire for Action { | ||
| 385 | 386 | entry_id.enc(e)?; |
| 386 | 387 | list_id.enc(e) |
| 387 | 388 | } |
| 389 | 추가: Self::CreateSevenZip { | |
| 390 | 추가: sources, | |
| 391 | 추가: output_file, | |
| 392 | 추가: method, | |
| 393 | 추가: solid, | |
| 394 | 추가: encryption, | |
| 395 | 추가: } => { | |
| 396 | 추가: 4u8.enc(e)?; | |
| 397 | 추가: sources.enc(e)?; | |
| 398 | 추가: output_file.enc(e)?; | |
| 399 | 추가: method.enc(e)?; | |
| 400 | 추가: solid.enc(e)?; | |
| 401 | 추가: encryption.enc(e) | |
| 402 | 추가: } | |
| 388 | 403 | } |
| 389 | 404 | } |
| 390 | 405 | fn dec(d: &mut Decoder<'_>) -> io::Result<Self> { |
| @@ -410,6 +425,13 @@ impl Wire for Action { | ||
| 410 | 425 | entry_id: Wire::dec(d)?, |
| 411 | 426 | list_id: Wire::dec(d)?, |
| 412 | 427 | }), |
| 428 | 추가: 4 => Ok(Self::CreateSevenZip { | |
| 429 | 추가: sources: Wire::dec(d)?, | |
| 430 | 추가: output_file: Wire::dec(d)?, | |
| 431 | 추가: method: Wire::dec(d)?, | |
| 432 | 추가: solid: Wire::dec(d)?, | |
| 433 | 추가: encryption: Wire::dec(d)?, | |
| 434 | 추가: }), | |
| 413 | 435 | _ => Err(invalid()), |
| 414 | 436 | } |
| 415 | 437 | } |
| @@ -1625,3 +1625,5 @@ mod compressed_tar; | ||
| 1625 | 1625 | mod guarded; |
| 1626 | 1626 | |
| 1627 | 1627 | mod split_runtime; |
| 1628 | 추가: | |
| 1629 | 추가: mod seven_zip_create; |
| @@ -0,0 +1,410 @@ | ||
| 1 | 추가: use super::*; | |
| 2 | 추가: | |
| 3 | 추가: fn request(windows: bool) -> Action { | |
| 4 | 추가: let (source, output_file) = if windows { | |
| 5 | 추가: ( | |
| 6 | 추가: NativePath::Windows("C:\\s".encode_utf16().collect()), | |
| 7 | 추가: NativePath::Windows("C:\\o.7z".encode_utf16().collect()), | |
| 8 | 추가: ) | |
| 9 | 추가: } else { | |
| 10 | 추가: ( | |
| 11 | 추가: NativePath::Unix(b"/s".to_vec()), | |
| 12 | 추가: NativePath::Unix(b"/o.7z".to_vec()), | |
| 13 | 추가: ) | |
| 14 | 추가: }; | |
| 15 | 추가: Action::CreateSevenZip { | |
| 16 | 추가: sources: vec![Source { | |
| 17 | 추가: path: source, | |
| 18 | 추가: archive_name: "한글".to_owned(), | |
| 19 | 추가: }], | |
| 20 | 추가: output_file, | |
| 21 | 추가: method: SevenZipMethod::Lzma2, | |
| 22 | 추가: solid: false, | |
| 23 | 추가: encryption: Encryption::None, | |
| 24 | 추가: } | |
| 25 | 추가: } | |
| 26 | 추가: | |
| 27 | 추가: fn start(action: Action) -> Start { | |
| 28 | 추가: Start { | |
| 29 | 추가: action, | |
| 30 | 추가: limits: Limits::default(), | |
| 31 | 추가: } | |
| 32 | 추가: } | |
| 33 | 추가: | |
| 34 | 추가: fn guarded(start: Start) -> GuardedStart { | |
| 35 | 추가: GuardedStart { | |
| 36 | 추가: ceiling: Limits { | |
| 37 | 추가: input: start.limits.input, | |
| 38 | 추가: output: 64 * 1024 * 1024 * 1024, | |
| 39 | 추가: entries: 200_000, | |
| 40 | 추가: }, | |
| 41 | 추가: start, | |
| 42 | 추가: interactive: false, | |
| 43 | 추가: } | |
| 44 | 추가: } | |
| 45 | 추가: | |
| 46 | 추가: fn encode(message: &Message) -> Vec<u8> { | |
| 47 | 추가: let mut bytes = Vec::new(); | |
| 48 | 추가: Writer::new(&mut bytes, 17).send(message).unwrap(); | |
| 49 | 추가: bytes | |
| 50 | 추가: } | |
| 51 | 추가: | |
| 52 | 추가: fn decode(bytes: &[u8]) -> Message { | |
| 53 | 추가: let mut reader = Reader::new(bytes); | |
| 54 | 추가: let (job, sequence, message) = reader.read().unwrap().unwrap(); | |
| 55 | 추가: assert_eq!((job, sequence), (17, 0)); | |
| 56 | 추가: assert!(reader.read().unwrap().is_none()); | |
| 57 | 추가: message | |
| 58 | 추가: } | |
| 59 | 추가: | |
| 60 | 추가: fn raw(kind: u16, body: &[u8]) -> Vec<u8> { | |
| 61 | 추가: let mut bytes = b"ZAW1\x01\x00".to_vec(); | |
| 62 | 추가: bytes.extend(kind.to_le_bytes()); | |
| 63 | 추가: bytes.extend((body.len() as u32).to_le_bytes()); | |
| 64 | 추가: bytes.extend([0; 4]); | |
| 65 | 추가: bytes.extend(17u64.to_le_bytes()); | |
| 66 | 추가: bytes.extend(0u64.to_le_bytes()); | |
| 67 | 추가: bytes.extend(body); | |
| 68 | 추가: bytes | |
| 69 | 추가: } | |
| 70 | 추가: | |
| 71 | 추가: fn reject_encode(message: Message) { | |
| 72 | 추가: let mut bytes = Vec::new(); | |
| 73 | 추가: assert_eq!( | |
| 74 | 추가: Writer::new(&mut bytes, 17) | |
| 75 | 추가: .send(&message) | |
| 76 | 추가: .unwrap_err() | |
| 77 | 추가: .kind(), | |
| 78 | 추가: std::io::ErrorKind::InvalidData | |
| 79 | 추가: ); | |
| 80 | 추가: assert!(bytes.is_empty()); | |
| 81 | 추가: } | |
| 82 | 추가: | |
| 83 | 추가: fn reject_decode(bytes: &[u8]) { | |
| 84 | 추가: assert_eq!( | |
| 85 | 추가: Reader::new(bytes).read().unwrap_err().kind(), | |
| 86 | 추가: std::io::ErrorKind::InvalidData | |
| 87 | 추가: ); | |
| 88 | 추가: } | |
| 89 | 추가: | |
| 90 | 추가: #[test] | |
| 91 | 추가: fn request_preserves_agreed_field_order_and_native_encodings() { | |
| 92 | 추가: for windows in [false, true] { | |
| 93 | 추가: let start = start(request(windows)); | |
| 94 | 추가: assert_eq!(start.action.kind(), ActionKind::CreateSevenZip); | |
| 95 | 추가: let mut expected = vec![4, 1, 0, 0, 0]; | |
| 96 | 추가: if windows { | |
| 97 | 추가: expected.extend(b"\x02\x04\x00\x00\x00C\x00:\x00\\\x00s\x00"); | |
| 98 | 추가: } else { | |
| 99 | 추가: expected.extend(b"\x01\x02\x00\x00\x00/s"); | |
| 100 | 추가: } | |
| 101 | 추가: expected.extend(b"\x06\x00\x00\x00\xed\x95\x9c\xea\xb8\x80"); | |
| 102 | 추가: if windows { | |
| 103 | 추가: expected.extend(b"\x02\x07\x00\x00\x00C\x00:\x00\\\x00o\x00.\x007\x00z\x00"); | |
| 104 | 추가: } else { | |
| 105 | 추가: expected.extend(b"\x01\x05\x00\x00\x00/o.7z"); | |
| 106 | 추가: } | |
| 107 | 추가: expected.extend([0, 0, 0]); | |
| 108 | 추가: expected.extend(u64::MAX.to_le_bytes()); | |
| 109 | 추가: expected.extend((16u64 * 1024 * 1024 * 1024).to_le_bytes()); | |
| 110 | 추가: expected.extend(10_000u32.to_le_bytes()); | |
| 111 | 추가: let bytes = encode(&Message::Start(start.clone())); | |
| 112 | 추가: assert_eq!(bytes, raw(1, &expected)); | |
| 113 | 추가: match decode(&bytes) { | |
| 114 | 추가: Message::Start(actual) => assert_eq!(actual, start), | |
| 115 | 추가: other => panic!("{other:?}"), | |
| 116 | 추가: } | |
| 117 | 추가: let guarded = guarded(start); | |
| 118 | 추가: assert!(guarded.valid()); | |
| 119 | 추가: expected.extend(u64::MAX.to_le_bytes()); | |
| 120 | 추가: expected.extend((64u64 * 1024 * 1024 * 1024).to_le_bytes()); | |
| 121 | 추가: expected.extend(200_000u32.to_le_bytes()); | |
| 122 | 추가: expected.push(0); | |
| 123 | 추가: let bytes = encode(&Message::StartGuarded(guarded.clone())); | |
| 124 | 추가: assert_eq!(bytes, raw(6, &expected)); | |
| 125 | 추가: match decode(&bytes) { | |
| 126 | 추가: Message::StartGuarded(actual) => assert_eq!(actual, guarded), | |
| 127 | 추가: other => panic!("{other:?}"), | |
| 128 | 추가: } | |
| 129 | 추가: } | |
| 130 | 추가: } | |
| 131 | 추가: | |
| 132 | 추가: #[test] | |
| 133 | 추가: fn unsupported_options_remain_structurally_valid_without_silent_conversion() { | |
| 134 | 추가: for solid in [false, true] { | |
| 135 | 추가: for encryption in [Encryption::None, Encryption::Aes256] { | |
| 136 | 추가: let mut action = request(false); | |
| 137 | 추가: if let Action::CreateSevenZip { | |
| 138 | 추가: solid: actual_solid, | |
| 139 | 추가: encryption: actual_encryption, | |
| 140 | 추가: .. | |
| 141 | 추가: } = &mut action | |
| 142 | 추가: { | |
| 143 | 추가: *actual_solid = solid; | |
| 144 | 추가: *actual_encryption = encryption; | |
| 145 | 추가: } | |
| 146 | 추가: let start = start(action); | |
| 147 | 추가: match decode(&encode(&Message::Start(start.clone()))) { | |
| 148 | 추가: Message::Start(actual) => assert_eq!(actual, start), | |
| 149 | 추가: other => panic!("{other:?}"), | |
| 150 | 추가: } | |
| 151 | 추가: } | |
| 152 | 추가: } | |
| 153 | 추가: } | |
| 154 | 추가: | |
| 155 | 추가: #[test] | |
| 156 | 추가: fn creation_never_accepts_interactive_conflict_requests() { | |
| 157 | 추가: let start = start(request(false)); | |
| 158 | 추가: reject_encode(Message::StartInteractive(start.clone())); | |
| 159 | 추가: let bytes = encode(&Message::Start(start.clone())); | |
| 160 | 추가: reject_decode(&raw(4, &bytes[32..])); | |
| 161 | 추가: let mut guarded = guarded(start); | |
| 162 | 추가: guarded.interactive = true; | |
| 163 | 추가: assert!(!guarded.valid()); | |
| 164 | 추가: reject_encode(Message::StartGuarded(guarded)); | |
| 165 | 추가: let mut bytes = encode(&Message::StartGuarded(self::guarded(self::start(request( | |
| 166 | 추가: false, | |
| 167 | 추가: ))))); | |
| 168 | 추가: *bytes.last_mut().unwrap() = 1; | |
| 169 | 추가: reject_decode(&bytes); | |
| 170 | 추가: } | |
| 171 | 추가: | |
| 172 | 추가: #[test] | |
| 173 | 추가: fn truncated_unknown_and_trailing_creation_fields_are_rejected() { | |
| 174 | 추가: for windows in [false, true] { | |
| 175 | 추가: let bytes = encode(&Message::Start(start(request(windows)))); | |
| 176 | 추가: let body = &bytes[32..]; | |
| 177 | 추가: for length in 0..body.len() { | |
| 178 | 추가: reject_decode(&raw(1, &body[..length])); | |
| 179 | 추가: } | |
| 180 | 추가: let mut trailing = body.to_vec(); | |
| 181 | 추가: trailing.push(0); | |
| 182 | 추가: reject_decode(&raw(1, &trailing)); | |
| 183 | 추가: let method = body.len() - 20 - 3; | |
| 184 | 추가: for (at, value) in [(0, 5), (method, 1), (method + 1, 2), (method + 2, 2)] { | |
| 185 | 추가: let mut body = body.to_vec(); | |
| 186 | 추가: body[at] = value; | |
| 187 | 추가: reject_decode(&raw(1, &body)); | |
| 188 | 추가: } | |
| 189 | 추가: } | |
| 190 | 추가: } | |
| 191 | 추가: | |
| 192 | 추가: #[test] | |
| 193 | 추가: fn guarded_approval_never_expands_source_vector_string_or_path_wire_limits() { | |
| 194 | 추가: let mut action = request(false); | |
| 195 | 추가: if let Action::CreateSevenZip { sources, .. } = &mut action { | |
| 196 | 추가: sources[0].archive_name = "a".repeat(32_768); | |
| 197 | 추가: } | |
| 198 | 추가: let guarded = guarded(start(action.clone())); | |
| 199 | 추가: assert!(matches!( | |
| 200 | 추가: decode(&encode(&Message::StartGuarded(guarded))), | |
| 201 | 추가: Message::StartGuarded(_) | |
| 202 | 추가: )); | |
| 203 | 추가: if let Action::CreateSevenZip { sources, .. } = &mut action { | |
| 204 | 추가: sources[0].archive_name.push('a'); | |
| 205 | 추가: } | |
| 206 | 추가: reject_encode(Message::StartGuarded(self::guarded(start(action)))); | |
| 207 | 추가: for windows in [false, true] { | |
| 208 | 추가: let mut action = request(windows); | |
| 209 | 추가: if let Action::CreateSevenZip { sources, .. } = &mut action { | |
| 210 | 추가: sources[0].path = if windows { | |
| 211 | 추가: NativePath::Windows(vec![b'a' as u16; 32_769]) | |
| 212 | 추가: } else { | |
| 213 | 추가: NativePath::Unix(vec![b'a'; 32_769]) | |
| 214 | 추가: }; | |
| 215 | 추가: } | |
| 216 | 추가: reject_encode(Message::StartGuarded(self::guarded(start(action)))); | |
| 217 | 추가: } | |
| 218 | 추가: let mut action = request(false); | |
| 219 | 추가: if let Action::CreateSevenZip { sources, .. } = &mut action { | |
| 220 | 추가: *sources = vec![sources[0].clone(); 32_769]; | |
| 221 | 추가: } | |
| 222 | 추가: reject_encode(Message::StartGuarded(self::guarded(start(action)))); | |
| 223 | 추가: let bytes = encode(&Message::StartGuarded(self::guarded(start(request(false))))); | |
| 224 | 추가: for at in [1, 6, 12] { | |
| 225 | 추가: let mut body = bytes[32..].to_vec(); | |
| 226 | 추가: body[at..at + 4].copy_from_slice(&32_769u32.to_le_bytes()); | |
| 227 | 추가: reject_decode(&raw(6, &body)); | |
| 228 | 추가: } | |
| 229 | 추가: } | |
| 230 | 추가: | |
| 231 | 추가: #[test] | |
| 232 | 추가: fn action_kind_events_keep_existing_tags_and_append_creation_tag_four() { | |
| 233 | 추가: for (tag, action) in [ | |
| 234 | 추가: ActionKind::List, | |
| 235 | 추가: ActionKind::Extract, | |
| 236 | 추가: ActionKind::CreateZip, | |
| 237 | 추가: ActionKind::Preview, | |
| 238 | 추가: ActionKind::CreateSevenZip, | |
| 239 | 추가: ] | |
| 240 | 추가: .into_iter() | |
| 241 | 추가: .enumerate() | |
| 242 | 추가: { | |
| 243 | 추가: let encryption = action != ActionKind::CreateSevenZip; | |
| 244 | 추가: let bytes = encode(&Message::Accepted { action, encryption }); | |
| 245 | 추가: assert_eq!(bytes, raw(100, &[tag as u8, u8::from(encryption)])); | |
| 246 | 추가: assert!( | |
| 247 | 추가: matches!(decode(&bytes), Message::Accepted { action: actual, encryption: value } if actual == action && value == encryption) | |
| 248 | 추가: ); | |
| 249 | 추가: let scope = ResourceScope { | |
| 250 | 추가: entries: true, | |
| 251 | 추가: ..ResourceScope::default() | |
| 252 | 추가: }; | |
| 253 | 추가: let bytes = encode(&Message::ResourceRequired { | |
| 254 | 추가: challenge_id: 23, | |
| 255 | 추가: action, | |
| 256 | 추가: scope, | |
| 257 | 추가: usage: ResourceUsage::default(), | |
| 258 | 추가: soft_limits: Limits::default(), | |
| 259 | 추가: ceiling: guarded(start(request(false))).ceiling, | |
| 260 | 추가: }); | |
| 261 | 추가: assert_eq!(bytes[32 + 8], tag as u8); | |
| 262 | 추가: assert!( | |
| 263 | 추가: matches!(decode(&bytes), Message::ResourceRequired { action: actual, scope: value, .. } if actual == action && value == scope) | |
| 264 | 추가: ); | |
| 265 | 추가: let mut body = bytes[32..].to_vec(); | |
| 266 | 추가: body[8] = 5; | |
| 267 | 추가: reject_decode(&raw(110, &body)); | |
| 268 | 추가: } | |
| 269 | 추가: reject_decode(&raw(100, &[5, 0])); | |
| 270 | 추가: } | |
| 271 | 추가: | |
| 272 | 추가: #[test] | |
| 273 | 추가: fn zip_methods_and_existing_request_bytes_stay_independent() { | |
| 274 | 추가: for (tag, method) in [(0, Method::Store), (1, Method::Deflate)] { | |
| 275 | 추가: let action = Action::CreateZip { | |
| 276 | 추가: sources: Vec::new(), | |
| 277 | 추가: output_file: NativePath::Unix(b"/a.zip".to_vec()), | |
| 278 | 추가: method, | |
| 279 | 추가: encryption: Encryption::Aes256, | |
| 280 | 추가: }; | |
| 281 | 추가: let start = start(action); | |
| 282 | 추가: let mut body = b"\x02\x00\x00\x00\x00\x01\x06\x00\x00\x00/a.zip".to_vec(); | |
| 283 | 추가: body.extend([tag, 1]); | |
| 284 | 추가: body.extend(u64::MAX.to_le_bytes()); | |
| 285 | 추가: body.extend((16u64 * 1024 * 1024 * 1024).to_le_bytes()); | |
| 286 | 추가: body.extend(10_000u32.to_le_bytes()); | |
| 287 | 추가: assert_eq!(encode(&Message::Start(start.clone())), raw(1, &body)); | |
| 288 | 추가: assert!(matches!(decode(&raw(1, &body)), Message::Start(actual) if actual == start)); | |
| 289 | 추가: body[16] = 2; | |
| 290 | 추가: reject_decode(&raw(1, &body)); | |
| 291 | 추가: } | |
| 292 | 추가: } | |
| 293 | 추가: | |
| 294 | 추가: struct Temporary(PathBuf); | |
| 295 | 추가: impl Temporary { | |
| 296 | 추가: fn new() -> Self { | |
| 297 | 추가: let root = std::env::var_os("TMPDIR") | |
| 298 | 추가: .map(PathBuf::from) | |
| 299 | 추가: .unwrap_or_else(|| { | |
| 300 | 추가: PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../tests/work/tmp") | |
| 301 | 추가: }); | |
| 302 | 추가: fs::create_dir_all(&root).unwrap(); | |
| 303 | 추가: let path = root.canonicalize().unwrap().join(format!( | |
| 304 | 추가: "zipelo-seven-create-{}-{}", | |
| 305 | 추가: std::process::id(), | |
| 306 | 추가: NEXT.fetch_add(1, Ordering::Relaxed) | |
| 307 | 추가: )); | |
| 308 | 추가: fs::create_dir(&path).unwrap(); | |
| 309 | 추가: Self(path) | |
| 310 | 추가: } | |
| 311 | 추가: fn run(&self, message: Message) -> Vec<Message> { | |
| 312 | 추가: let output = self.0.join("saved.7z"); | |
| 313 | 추가: fs::write(&output, b"existing user data").unwrap(); | |
| 314 | 추가: let bytes = encode(&message); | |
| 315 | 추가: let mut child = Command::new(env!("CARGO_BIN_EXE_zipelo-archive-worker")) | |
| 316 | 추가: .env("TMPDIR", self.0.join("unavailable-temp")) | |
| 317 | 추가: .env("TMP", self.0.join("unavailable-temp")) | |
| 318 | 추가: .env("TEMP", self.0.join("unavailable-temp")) | |
| 319 | 추가: .stdin(Stdio::piped()) | |
| 320 | 추가: .stdout(Stdio::piped()) | |
| 321 | 추가: .stderr(Stdio::piped()) | |
| 322 | 추가: .spawn() | |
| 323 | 추가: .unwrap(); | |
| 324 | 추가: child.stdin.take().unwrap().write_all(&bytes).unwrap(); | |
| 325 | 추가: let output = child.wait_with_output().unwrap(); | |
| 326 | 추가: assert!(output.status.success(), "{:?}", output.stderr); | |
| 327 | 추가: assert!(output.stderr.is_empty()); | |
| 328 | 추가: let mut reader = Reader::new(output.stdout.as_slice()); | |
| 329 | 추가: let mut events = Vec::new(); | |
| 330 | 추가: while let Some((job, _, message)) = reader.read().unwrap() { | |
| 331 | 추가: assert_eq!(job, 17); | |
| 332 | 추가: events.push(message); | |
| 333 | 추가: } | |
| 334 | 추가: assert_eq!( | |
| 335 | 추가: fs::read(self.0.join("saved.7z")).unwrap(), | |
| 336 | 추가: b"existing user data" | |
| 337 | 추가: ); | |
| 338 | 추가: assert_eq!(fs::read_dir(&self.0).unwrap().count(), 1); | |
| 339 | 추가: events | |
| 340 | 추가: } | |
| 341 | 추가: } | |
| 342 | 추가: impl Drop for Temporary { | |
| 343 | 추가: fn drop(&mut self) { | |
| 344 | 추가: fs::remove_dir_all(&self.0).expect("7z 생성 시험 임시 폴더 정리에 실패함"); | |
| 345 | 추가: } | |
| 346 | 추가: } | |
| 347 | 추가: | |
| 348 | 추가: #[test] | |
| 349 | 추가: fn pending_writer_and_unsupported_options_fail_before_questions_or_file_access() { | |
| 350 | 추가: let temporary = Temporary::new(); | |
| 351 | 추가: for solid in [false, true] { | |
| 352 | 추가: for encryption in [Encryption::None, Encryption::Aes256] { | |
| 353 | 추가: for kind in [1, 6, 7] { | |
| 354 | 추가: let action = Action::CreateSevenZip { | |
| 355 | 추가: sources: vec![Source { | |
| 356 | 추가: path: NativePath::from_path(&temporary.0.join("missing/source")), | |
| 357 | 추가: archive_name: "source".to_owned(), | |
| 358 | 추가: }], | |
| 359 | 추가: output_file: NativePath::from_path(&temporary.0.join("saved.7z")), | |
| 360 | 추가: method: SevenZipMethod::Lzma2, | |
| 361 | 추가: solid, | |
| 362 | 추가: encryption, | |
| 363 | 추가: }; | |
| 364 | 추가: let start = start(action); | |
| 365 | 추가: let message = if kind == 1 { | |
| 366 | 추가: Message::Start(start) | |
| 367 | 추가: } else { | |
| 368 | 추가: let mut guarded = guarded(start); | |
| 369 | 추가: if kind == 7 { | |
| 370 | 추가: guarded.ceiling = guarded.start.limits; | |
| 371 | 추가: } | |
| 372 | 추가: Message::StartGuarded(guarded) | |
| 373 | 추가: }; | |
| 374 | 추가: let events = temporary.run(message); | |
| 375 | 추가: assert_eq!(events.len(), 2, "{events:?}"); | |
| 376 | 추가: assert!(matches!( | |
| 377 | 추가: events[0], | |
| 378 | 추가: Message::Accepted { | |
| 379 | 추가: action: ActionKind::CreateSevenZip, | |
| 380 | 추가: encryption: false | |
| 381 | 추가: } | |
| 382 | 추가: )); | |
| 383 | 추가: let terminal = terminal(&events); | |
| 384 | 추가: assert_eq!(terminal.outcome, Outcome::Failed); | |
| 385 | 추가: assert_eq!(terminal.error, ErrorCode::UnsupportedFeature); | |
| 386 | 추가: assert_eq!(terminal.publication, Publication::None); | |
| 387 | 추가: assert_eq!(terminal.created_count, 0); | |
| 388 | 추가: assert_eq!(terminal.retained_partial_count, 0); | |
| 389 | 추가: assert_eq!(terminal.cleanup, Cleanup::Complete); | |
| 390 | 추가: assert_eq!(terminal.durability, Durability::NotApplicable); | |
| 391 | 추가: } | |
| 392 | 추가: } | |
| 393 | 추가: } | |
| 394 | 추가: } | |
| 395 | 추가: | |
| 396 | 추가: #[test] | |
| 397 | 추가: fn existing_runtime_encryption_capability_is_preserved() { | |
| 398 | 추가: let temporary = Temporary::new(); | |
| 399 | 추가: let events = temporary.run(Message::Start(start(Action::List { | |
| 400 | 추가: archive: NativePath::from_path(&temporary.0.join("missing.zip")), | |
| 401 | 추가: }))); | |
| 402 | 추가: assert!(matches!( | |
| 403 | 추가: events[0], | |
| 404 | 추가: Message::Accepted { | |
| 405 | 추가: action: ActionKind::List, | |
| 406 | 추가: encryption: true | |
| 407 | 추가: } | |
| 408 | 추가: )); | |
| 409 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Failed); | |
| 410 | 추가: } |