기본 앱 제거 기능에 최신 main 변경을 병합함
- 작성자
- 코노모리 카논
- 작성 시각
- 커밋
5563a16cefe5b9c22d86de197d76acab1c43bcdd
변경된 파일 41개
+1,822-98변경 내용이 커서 일부 파일의 Diff를 생략했어요. 생략한 파일은 파일 보기나 Raw로 확인할 수 있어요.
| @@ -10,6 +10,8 @@ | ||
| 10 | 10 | |
| 11 | 11 | ## 이런 걸 할 수 있어요 |
| 12 | 12 | |
| 13 | 추가: 아래 사용 안내는 다운로드로 제공하는 v0.1.0 기준입니다. | |
| 14 | 추가: | |
| 13 | 15 | - **압축 풀기:** [열기]로 압축 파일을 고르거나 창에 끌어 놓으세요. [압축해제]를 누르고 저장할 곳을 고르면 됩니다. 원하는 파일과 폴더만 선택해서 풀 수도 있습니다. |
| 14 | 16 | - **ZIP 만들기:** [압축하기]를 눌러 묶을 폴더를 고른 뒤, ZIP 만들기 창에서 [압축하기]를 누르고 저장할 이름과 위치를 정하세요. |
| 15 | 17 | - **암호로 보호하기:** ZIP을 만들 때 [암호로 보호하기]를 켜면 암호를 설정할 수 있습니다. 암호가 걸린 ZIP을 풀 때는 암호를 입력합니다. |
| @@ -30,7 +32,7 @@ Ubuntu에서는 [.deb 설치 파일](https://github.com/Team-LJY/zipelo/releases | ||
| 30 | 32 | ## 아직 안 되는 것과 사용 전 알아둘 점 |
| 31 | 33 | |
| 32 | 34 | - RAR 열기, 손상된 압축 파일 복구, 파일 내용 미리보기는 지원하지 않습니다. |
| 33 | 삭제: - 여러 조각으로 나뉜 압축 파일, 7z 만들기, TAR.BZ2와 TAR.XZ는 지원하지 않습니다. | |
| 35 | 추가: - 여러 조각으로 나뉜 압축 파일과 7z 만들기는 지원하지 않습니다. TAR.BZ2와 TAR.XZ 풀기는 개발 중인 main에서 해결됐으며([PR119](https://github.com/Team-LJY/zipelo/pull/119)), 게시된 v0.1.0에는 포함되지 않습니다. Wayland 파일 선택 창과 릴리스 설치 패키지 검증은 남아 있습니다. | |
| 34 | 36 | - 한 번에 푸는 파일의 전체 크기와 ZIP으로 묶는 원본의 전체 크기는 각각 16 GiB까지입니다. |
| 35 | 37 | - Zipelo에서 암호를 걸어 만든 ZIP은 Windows 탐색기의 기본 압축 기능으로 열 수 없습니다. Zipelo나 7-Zip을 사용하세요. 암호를 잊으면 파일을 열 수 없습니다. |
| 36 | 38 | - 같은 이름의 파일을 덮어쓰지 않습니다. 이름이 겹치면 다른 저장 위치나 이름을 선택하세요. |
| @@ -41,6 +43,6 @@ Ubuntu에서는 [.deb 설치 파일](https://github.com/Team-LJY/zipelo/releases | ||
| 41 | 43 | |
| 42 | 44 | ## 개발자용 |
| 43 | 45 | |
| 44 | 삭제: Rust로 개발하며 압축 처리는 별도 작업자 프로세스에서 수행합니다. 로컬 빌드와 시험은 `python3 tests/ci/run_rust.py local`로 실행합니다. | |
| 46 | 추가: Rust로 개발하며 압축 처리는 별도 작업자 프로세스에서 수행합니다. 로컬 빌드와 시험은 `python3 tests/ci/run_rust.py local`로 실행합니다. 프로젝트 이동 뒤 긴 경로 때문에 시험 실행기가 멈추던 문제는 main에서 해결됐습니다([PR118](https://github.com/Team-LJY/zipelo/pull/118)). 새 실제 경로에서 별칭이나 경로 매핑 없이 전체 local 검증을 통과한 기록이 있습니다. | |
| 45 | 47 | |
| 46 | 48 | [기획서](docs/PLANS.md)와 [UI 설계](docs/ui-design-v0.1.md)를 참고하세요. 소스는 [MIT 라이선스](LICENSE)로 공개합니다. |
| @@ -81,7 +81,7 @@ python3 -B tests/rust-memory-gzip-reader/static_check.py \ | ||
| 81 | 81 | |
| 82 | 82 | ## 8. v0.2 한계 개선 계획 |
| 83 | 83 | |
| 84 | 삭제: 2026-11-13의 사용자 지시에 따라 [README](../README.md)와 [v0.1 릴리스 노트](release-notes-v0.1.md)의 한계를 개선 대상으로 관리한다. 아래 방법과 수용 기준은 계획안이며 구현 완료나 출시 약속이 아니다. v0.1의 제외 항목은 과거 범위로 유지한다. JAR와 앱/문서용 컨테이너 제외는 의도한 제품 범위이므로 이번 개선에 넣지 않는다. | |
| 84 | 추가: 2026-11-13의 사용자 지시에 따라 [README](../README.md)와 [v0.1 릴리스 노트](release-notes-v0.1.md)의 한계를 개선 대상으로 관리한다. 아래 방법과 수용 기준은 계획안이며, 해결됨 항목은 main 반영을 뜻하고 릴리스 배포 완료를 뜻하지 않는다. v0.1의 제외 항목은 과거 범위로 유지한다. JAR와 앱/문서용 컨테이너 제외는 의도한 제품 범위이므로 이번 개선에 넣지 않는다. | |
| 85 | 85 | |
| 86 | 86 | 우선순위 P1은 데이터 보존과 일상 사용의 장애 해결, P2는 형식 및 사용성 확장, P3는 범위가 큰 탐색 과제다. 작업 크기는 상대 추정으로 소는 단일 영역, 중은 여러 경로와 시험, 대는 형식 처리 또는 플랫폼 통합, 특대는 신규 처리 계층과 광범위한 검증을 뜻한다. 일정 추정은 아니며 상세 설계 후 조정한다. 배정됨으로 표시한 작업 외의 담당 역할은 제안이며 새 작업 배정을 뜻하지 않는다. |
| 87 | 87 | |
| @@ -115,10 +115,11 @@ python3 -B tests/rust-memory-gzip-reader/static_check.py \ | ||
| 115 | 115 | |
| 116 | 116 | ### 8.5 TAR.BZ2와 TAR.XZ 해제 |
| 117 | 117 | |
| 118 | 삭제: - 상태와 우선순위: 라이브러리 사용 승인, 배정됨, P2. backend가 같은 이름 충돌 작업자를 마친 뒤 `features/tar-bz2-xz`에서 진행한다. | |
| 119 | 삭제: - 해결 방법: 순수 Rust이며 허용된 자유 라이선스인 BZip2 및 XZ 해제 라이브러리를 골라 기존 TAR 처리에 연결한다. 지원 범위, 유지보수와 자원 제한을 확인하고 도입 PR에 선택 이유 및 배포 라이선스 고지를 포함한다. 특정 라이브러리의 적합성을 이 계획에서 확정하지 않는다. | |
| 120 | 삭제: - 작업 크기와 담당: 라이브러리 통합은 대로 추정한다. backend는 구현, bugfix는 리뷰와 호환 검증을 맡는다. frontend의 형식 및 오류 표시 변경이 필요하면 범위를 합의한다. | |
| 121 | 삭제: - 수용 기준: 두 형식의 정상 파일, 빈 파일, 잘린 입력, 손상, 큰 사전 요구, 압축 폭탄, 경로 이탈과 취소를 시험한다. 기준 도구로 푼 결과와 파일 해시가 일치하고 기존 16 GiB 한도, 여유 공간 확인 및 경로 안전 검사를 유지해야 한다. `packaging/licenses.py`가 만드는 고지에 새 라이브러리가 포함되어야 한다. | |
| 118 | 추가: - 상태와 우선순위: 해결됨(main 반영), P2. [PR119](https://github.com/Team-LJY/zipelo/pull/119)가 2026-11-13에 병합됐다. 게시된 v0.1.0에는 포함되지 않는다. | |
| 119 | 추가: - 해결 내용: 순수 Rust 해제 라이브러리를 기존 TAR 처리에 연결하고 파일 선택 필터, 지원 안내, 복합 확장자의 해제 폴더 이름과 UI 상황을 갱신했다. 기존 16 GiB 한도, 여유 공간 확인 및 경로 안전 검사를 유지하며 새 라이브러리는 배포 라이선스 고지에 포함했다. | |
| 120 | 추가: - 담당: backend 구현, frontend 화면 연동, bugfix 리뷰 및 Windows 호환 검증. | |
| 121 | 추가: - 검증 근거: PR119 기록상 손상 XZ 인덱스 회귀를 포함한 압축 TAR 시험 17개와 전체 local의 Rust 시험 1,112개가 통과했다. 해당 local 실행은 PR118 반영 전의 짧은 경로 매핑을 사용했다. Windows 11에서 두 형식을 실제 해제해 각 4개 파일의 원본 해시 일치와 기본 파일 선택 창 표시를 확인했다. | |
| 122 | 추가: - 남은 검증: Wayland 기본 파일 선택 창과 Windows 릴리스 설치 패키지는 미검증이다. 이 기록은 병합된 main에서 전체 시험을 다시 실행한 결과가 아니다. | |
| 122 | 123 | |
| 123 | 124 | ### 8.6 암호 ZIP의 Windows 탐색기 호환 제외 |
| 124 | 125 | |
| @@ -164,6 +165,8 @@ python3 -B tests/rust-memory-gzip-reader/static_check.py \ | ||
| 164 | 165 | |
| 165 | 166 | ### 8.12 나머지 위험과 검증 범위 |
| 166 | 167 | |
| 168 | 추가: - 프로젝트 이동 후 시험 실행기 중단: 해결됨(main 반영). [PR118](https://github.com/Team-LJY/zipelo/pull/118)이 2026-11-13에 병합됐다. 시험 소켓을 상대 경로로 바인딩해 긴 절대 경로의 길이 제한을 피하며 실제 파일 위치와 기존 안전 검사를 유지한다. 작성자는 새 실제 경로에서 별칭이나 경로 매핑 없이 전체 local 63단계(Linux 빌드, 시험, Windows 교차 빌드 각 21단계) 통과를 기록했고, 리뷰어는 실행기 시험 42개와 파일 게시 시험 55개를 직접 확인했다. Windows 실제 실행 검증을 뜻하지 않는다. | |
| 169 | 추가: | |
| 167 | 170 | - 부분 출력과 임시 파일: P1, 중. backend와 bugfix가 실패 및 취소 시 남은 출력 목록과 재정리 방법을 검토한다. 디스크 부족, 동기화 실패와 정리 실패를 주입해 성공 오표시가 없고 무관한 파일을 지우지 않는 것을 수용 기준으로 한다. frontend는 필요한 결과 안내를 맡는다. |
| 168 | 171 | - 플랫폼 검증 공백: P2, 중. bugfix가 Windows 재부팅 후 연결, 지원 대상으로 정한 Windows와 Ubuntu 버전, 잘못된 암호 재시도 및 실제 UI 상황 명령 실행을 확인하는 안이다. 결과에 OS 버전과 실행한 흐름을 남기고 미검증 환경을 지원 완료로 표현하지 않는다. 이미 확인한 Wayland 아이콘과 Windows 다섯 확장자 연결은 관련 변경이 있을 때 회귀 검증한다. |
| 169 | 172 | - 설치 파일 서명 부재: P2, 중. planning이 서명 방식과 비용을 정리하고 설치 담당과 적용 범위를 합의하는 안이다. 인증서 구매와 서명은 이준영 님 결정 대기이며, 수용 기준은 승인된 방식의 서명 검증과 실제 설치 안내 확인이다. 서명만으로 모든 운영체제 경고가 사라진다고 약속하지 않는다. |
| @@ -171,7 +174,7 @@ python3 -B tests/rust-memory-gzip-reader/static_check.py \ | ||
| 171 | 174 | |
| 172 | 175 | ### 8.13 진행과 완료 판단 |
| 173 | 176 | |
| 174 | 삭제: - 우선 배정된 충돌 처리와 Windows 업데이트를 검증하고, TAR.BZ2/XZ는 작업자 충돌 처리 이후 진행한다. RAR 압축과 해제는 v0.2에서 제외하며 라이선스 걱정 없이 쓸 방법이 확인될 때만 다시 검토한다. 암호 ZIP의 Windows 탐색기 호환은 목표에서 제외한다. 나머지 후보의 우선순위와 크기는 검토안이며 동시 착수를 지시하지 않는다. | |
| 177 | 추가: - 우선 배정된 충돌 처리와 Windows 업데이트를 검증하고, TAR.BZ2/XZ와 프로젝트 이동 후 시험 실행기 중단 문제는 main에서 해결됐다(8.5절, 8.12절). RAR 압축과 해제는 v0.2에서 제외하며 라이선스 걱정 없이 쓸 방법이 확인될 때만 다시 검토한다. 암호 ZIP의 Windows 탐색기 호환은 목표에서 제외한다. 나머지 후보의 우선순위와 크기는 검토안이며 동시 착수를 지시하지 않는다. | |
| 175 | 178 | - 2026-11-13 사용자 결정과 갱신된 팀 규칙에 따라 순수 Rust이고 MIT, Apache, BSD, zlib 같은 자유 라이선스인 외부 라이브러리를 사용할 수 있다. 도입 PR에 선택 이유와 라이선스 고지를 포함하고 packaging/licenses.py의 배포 고지에 반영한다. 이 기준 밖의 의존성은 사전 확인을 받는다. RAR 압축과 해제 제외 및 공식 unRAR 코드 사용 금지는 별도로 유지한다. 공용 계약은 backend와 frontend 합의가 선행되어야 한다. |
| 176 | 179 | - 제품 변경 PR은 해당 회귀 시험과 `python3 tests/ci/run_rust.py local` 결과를 기록하고, 설치 변경은 패키지 시험과 플랫폼 실기를 포함한다. 시험 및 시험용 도구는 프로젝트 루트의 `tests/` 아래에만 둔다. |
| 177 | 180 | - 화면이 바뀌면 같은 PR에서 `--ui-scenario` 상황, 시험 및 [상황별 UI 가이드](ui-scenario-guide.md)를 함께 갱신한다. 화면 변화가 없으면 PR 본문에 "UI 변경 없음"을 적는다. 사용자가 직접 올린 UI PR의 누락은 병합 뒤 frontend가 보완한다. |
| @@ -269,7 +269,7 @@ | ||
| 269 | 269 | |
| 270 | 270 | 고정 문구: |
| 271 | 271 | |
| 272 | 삭제: - 빈 화면: "압축파일을 여기에 끌어 놓으세요", "또는", "ZIP, 7z, TAR, GZ, TAR.GZ 파일을 열 수 있습니다", "놓으면 엽니다" | |
| 272 | 추가: - 빈 화면: "압축파일을 여기에 끌어 놓으세요", "또는", "ZIP, 7z, TAR, GZ, TAR.GZ, TAR.BZ2, TAR.XZ 파일을 열 수 있습니다", "놓으면 엽니다" | |
| 273 | 273 | - 닫기 확인 창 "작업 중 닫기": "작업을 취소하고 닫을까요?", 버튼 [계속 작업]과 [취소하고 닫기] |
| 274 | 274 | - "종료 확인 중" 창: "마무리하는 중입니다. 잠시만 기다려 주세요", 버튼 [닫기 취소] |
| 275 | 275 |
| @@ -42,6 +42,8 @@ cargo +1.99.1 build --locked --manifest-path experiments/rust-ui-memory-app/Carg | ||
| 42 | 42 | ## 상황과 확인할 점 |
| 43 | 43 | |
| 44 | 44 | - empty: 빈 첫 화면. 파일 열기 안내와 툴바 배치를 확인한다. |
| 45 | 추가: - tar-bz2: TAR.BZ2 목록. 제목표시줄의 파일 이름과 목록을 확인한다. | |
| 46 | 추가: - tar-xz: TAR.XZ 목록. 제목표시줄의 대소문자가 섞인 복합 확장자와 목록을 확인한다. | |
| 45 | 47 | - archive: 파일과 폴더가 있는 압축파일. 이름, 크기, 잠금 아이콘과 상태 줄을 확인한다. |
| 46 | 48 | - folder: 사진 폴더 내부. 상위 폴더 이동과 경로 줄을 확인한다. |
| 47 | 49 | - many-items: 기본 5개 외에 500개 파일을 추가한 목록. 스크롤바와 행 배치를 확인한다. |
| @@ -98,6 +100,8 @@ python3 tests/ci/run_rust.py local | ||
| 98 | 100 | 화면에 새 창, 버튼, 메시지, 상태 또는 오류를 추가하거나 바꾸면 같은 PR에서 상황, 시험과 이 가이드를 갱신한다. 화면 변화가 없으면 PR 본문에 "UI 변경 없음"이라고 적는다. 사용자가 직접 올린 UI 변경에서 빠진 상황은 병합 뒤 프론트엔드 담당이 보완한다. |
| 99 | 101 | |
| 100 | 102 | |
| 103 | 추가: TAR.BZ2와 TAR.XZ의 자동 해제 폴더 이름은 미리보기에 표시되지 않는다. tests/rust-app-ui/presentation.rs의 이름 시험과 tests/rust-app-real-worker/compressed_tar_flows.rs의 실제 작업자 시험에서 복합 확장자 제거와 해제 결과를 확인한다. | |
| 104 | 추가: | |
| 101 | 105 | ## 설치 프로그램의 제거 안내 |
| 102 | 106 | |
| 103 | 107 | Windows NSIS 제거 프로그램은 앱과 별도의 실행 파일입니다. 이번 제거 안내는 Uninstall.exe 실행 후 확인 화면 앞에 표시되며 [기본 앱 설정 열기]로 Windows 설정을 엽니다. --ui-scenario uninstall-windows와 uninstall-settings-error로 안내 문구를 확인합니다. Ubuntu 터미널 안내는 uninstall-ubuntu-missing과 uninstall-ubuntu-unknown-user로 확인합니다. 이 네 상황은 외부 설치 프로그램과 터미널의 문구를 egui에 재현한 읽기 전용 미리보기이며, NSIS의 실제 배치나 운영체제 창 모양을 재현하지 않습니다. 버튼은 설정을 열거나 제거를 실행하지 않습니다. 다른 운영체제에서도 같은 안내를 확인할 수 있습니다. |
| @@ -10,7 +10,7 @@ checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" | ||
| 10 | 10 | dependencies = [ |
| 11 | 11 | "cfg-if", |
| 12 | 12 | "cipher", |
| 13 | 삭제: "cpufeatures", | |
| 13 | 추가: "cpufeatures 0.2.17", | |
| 14 | 14 | "zeroize", |
| 15 | 15 | ] |
| 16 | 16 | |
| @@ -23,6 +23,24 @@ dependencies = [ | ||
| 23 | 23 | "generic-array", |
| 24 | 24 | ] |
| 25 | 25 | |
| 26 | 추가: [[package]] | |
| 27 | 추가: name = "block-buffer" | |
| 28 | 추가: version = "0.12.1" | |
| 29 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 30 | 추가: checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" | |
| 31 | 추가: dependencies = [ | |
| 32 | 추가: "hybrid-array", | |
| 33 | 추가: ] | |
| 34 | 추가: | |
| 35 | 추가: [[package]] | |
| 36 | 추가: name = "bzip2" | |
| 37 | 추가: version = "0.6.1" | |
| 38 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 39 | 추가: checksum = "f3a53fac24f34a81bc9954b5d6cfce0c21e18ec6959f44f56e8e90e4bb7c346c" | |
| 40 | 추가: dependencies = [ | |
| 41 | 추가: "libbz2-rs-sys", | |
| 42 | 추가: ] | |
| 43 | 추가: | |
| 26 | 44 | [[package]] |
| 27 | 45 | name = "cfg-if" |
| 28 | 46 | version = "1.0.5" |
| @@ -35,10 +53,16 @@ version = "0.4.4" | ||
| 35 | 53 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 36 | 54 | checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" |
| 37 | 55 | dependencies = [ |
| 38 | 삭제: "crypto-common", | |
| 56 | 추가: "crypto-common 0.1.7", | |
| 39 | 57 | "inout", |
| 40 | 58 | ] |
| 41 | 59 | |
| 60 | 추가: [[package]] | |
| 61 | 추가: name = "const-oid" | |
| 62 | 추가: version = "0.10.3" | |
| 63 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 64 | 추가: checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" | |
| 65 | 추가: | |
| 42 | 66 | [[package]] |
| 43 | 67 | name = "cpufeatures" |
| 44 | 68 | version = "0.2.17" |
| @@ -48,6 +72,15 @@ dependencies = [ | ||
| 48 | 72 | "libc", |
| 49 | 73 | ] |
| 50 | 74 | |
| 75 | 추가: [[package]] | |
| 76 | 추가: name = "cpufeatures" | |
| 77 | 추가: version = "0.3.1" | |
| 78 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 79 | 추가: checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" | |
| 80 | 추가: dependencies = [ | |
| 81 | 추가: "libc", | |
| 82 | 추가: ] | |
| 83 | 추가: | |
| 51 | 84 | [[package]] |
| 52 | 85 | name = "crypto-common" |
| 53 | 86 | version = "0.1.7" |
| @@ -58,17 +91,37 @@ dependencies = [ | ||
| 58 | 91 | "typenum", |
| 59 | 92 | ] |
| 60 | 93 | |
| 94 | 추가: [[package]] | |
| 95 | 추가: name = "crypto-common" | |
| 96 | 추가: version = "0.2.2" | |
| 97 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 98 | 추가: checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" | |
| 99 | 추가: dependencies = [ | |
| 100 | 추가: "hybrid-array", | |
| 101 | 추가: ] | |
| 102 | 추가: | |
| 61 | 103 | [[package]] |
| 62 | 104 | name = "digest" |
| 63 | 105 | version = "0.10.7" |
| 64 | 106 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 65 | 107 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" |
| 66 | 108 | dependencies = [ |
| 67 | 삭제: "block-buffer", | |
| 68 | 삭제: "crypto-common", | |
| 109 | 추가: "block-buffer 0.10.4", | |
| 110 | 추가: "crypto-common 0.1.7", | |
| 69 | 111 | "subtle", |
| 70 | 112 | ] |
| 71 | 113 | |
| 114 | 추가: [[package]] | |
| 115 | 추가: name = "digest" | |
| 116 | 추가: version = "0.11.3" | |
| 117 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 118 | 추가: checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" | |
| 119 | 추가: dependencies = [ | |
| 120 | 추가: "block-buffer 0.12.1", | |
| 121 | 추가: "const-oid", | |
| 122 | 추가: "crypto-common 0.2.2", | |
| 123 | 추가: ] | |
| 124 | 추가: | |
| 72 | 125 | [[package]] |
| 73 | 126 | name = "generic-array" |
| 74 | 127 | version = "0.14.7" |
| @@ -85,7 +138,16 @@ version = "0.12.1" | ||
| 85 | 138 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 86 | 139 | checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" |
| 87 | 140 | dependencies = [ |
| 88 | 삭제: "digest", | |
| 141 | 추가: "digest 0.10.7", | |
| 142 | 추가: ] | |
| 143 | 추가: | |
| 144 | 추가: [[package]] | |
| 145 | 추가: name = "hybrid-array" | |
| 146 | 추가: version = "0.4.15" | |
| 147 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 148 | 추가: checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" | |
| 149 | 추가: dependencies = [ | |
| 150 | 추가: "typenum", | |
| 89 | 151 | ] |
| 90 | 152 | |
| 91 | 153 | [[package]] |
| @@ -97,19 +159,34 @@ dependencies = [ | ||
| 97 | 159 | "generic-array", |
| 98 | 160 | ] |
| 99 | 161 | |
| 162 | 추가: [[package]] | |
| 163 | 추가: name = "libbz2-rs-sys" | |
| 164 | 추가: version = "0.2.6" | |
| 165 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 166 | 추가: checksum = "32f454fd6831a29c0e827ed075bca2a15be201bd57f4168f0fd1041124eab17e" | |
| 167 | 추가: | |
| 100 | 168 | [[package]] |
| 101 | 169 | name = "libc" |
| 102 | 170 | version = "0.2.191" |
| 103 | 171 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 104 | 172 | checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" |
| 105 | 173 | |
| 174 | 추가: [[package]] | |
| 175 | 추가: name = "lzma-rust2" | |
| 176 | 추가: version = "0.25.0" | |
| 177 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 178 | 추가: checksum = "ef1d73c59a56771343712b22ea5615092c612c16ba291c0979e3105dfeec4890" | |
| 179 | 추가: dependencies = [ | |
| 180 | 추가: "sha2 0.11.1", | |
| 181 | 추가: ] | |
| 182 | 추가: | |
| 106 | 183 | [[package]] |
| 107 | 184 | name = "pbkdf2" |
| 108 | 185 | version = "0.12.2" |
| 109 | 186 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 110 | 187 | checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" |
| 111 | 188 | dependencies = [ |
| 112 | 삭제: "digest", | |
| 189 | 추가: "digest 0.10.7", | |
| 113 | 190 | "hmac", |
| 114 | 191 | ] |
| 115 | 192 | |
| @@ -120,8 +197,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 120 | 197 | checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" |
| 121 | 198 | dependencies = [ |
| 122 | 199 | "cfg-if", |
| 123 | 삭제: "cpufeatures", | |
| 124 | 삭제: "digest", | |
| 200 | 추가: "cpufeatures 0.2.17", | |
| 201 | 추가: "digest 0.10.7", | |
| 125 | 202 | ] |
| 126 | 203 | |
| 127 | 204 | [[package]] |
| @@ -131,8 +208,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 131 | 208 | checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" |
| 132 | 209 | dependencies = [ |
| 133 | 210 | "cfg-if", |
| 134 | 삭제: "cpufeatures", | |
| 135 | 삭제: "digest", | |
| 211 | 추가: "cpufeatures 0.2.17", | |
| 212 | 추가: "digest 0.10.7", | |
| 213 | 추가: ] | |
| 214 | 추가: | |
| 215 | 추가: [[package]] | |
| 216 | 추가: name = "sha2" | |
| 217 | 추가: version = "0.11.1" | |
| 218 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 219 | 추가: checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" | |
| 220 | 추가: dependencies = [ | |
| 221 | 추가: "cfg-if", | |
| 222 | 추가: "cpufeatures 0.3.1", | |
| 223 | 추가: "digest 0.11.3", | |
| 136 | 224 | ] |
| 137 | 225 | |
| 138 | 226 | [[package]] |
| @@ -164,10 +252,12 @@ name = "zipelo-archive-worker" | ||
| 164 | 252 | version = "0.1.0" |
| 165 | 253 | dependencies = [ |
| 166 | 254 | "aes", |
| 255 | 추가: "bzip2", | |
| 167 | 256 | "hmac", |
| 257 | 추가: "lzma-rust2", | |
| 168 | 258 | "pbkdf2", |
| 169 | 259 | "sha1", |
| 170 | 삭제: "sha2", | |
| 260 | 추가: "sha2 0.10.9", | |
| 171 | 261 | "subtle", |
| 172 | 262 | "zeroize", |
| 173 | 263 | "zlib-rs", |
| @@ -7,6 +7,8 @@ publish = false | ||
| 7 | 7 | autotests = false |
| 8 | 8 | |
| 9 | 9 | [dependencies] |
| 10 | 추가: bzip2 = "=0.6.1" | |
| 11 | 추가: lzma-rust2 = { version = "=0.25.0", default-features = false, features = ["std", "xz"] } | |
| 10 | 12 | aes = { version = "=0.8.4", features = ["zeroize"] } |
| 11 | 13 | hmac = "=0.12.1" |
| 12 | 14 | pbkdf2 = { version = "=0.12.2", default-features = false, features = ["hmac"] } |
| @@ -25,3 +27,9 @@ path = "../../tests/rust-archive-worker/main.rs" | ||
| 25 | 27 | # 대용량 시험의 CRC와 Deflate에도 배포판의 최적화를 적용함. |
| 26 | 28 | [profile.dev.package.zlib-rs] |
| 27 | 29 | opt-level = 3 |
| 30 | 추가: | |
| 31 | 추가: [profile.dev.package.libbz2-rs-sys] | |
| 32 | 추가: opt-level = 3 | |
| 33 | 추가: | |
| 34 | 추가: [profile.dev.package.lzma-rust2] | |
| 35 | 추가: opt-level = 3 |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | # Rust archive worker |
| 2 | 2 | |
| 3 | 삭제: 별도 프로세스의 stdin/stdout으로 revision 2 요청을 처리합니다. 제품 앱이 공유 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 | 삭제: - ZIP32/ZIP64 Store/Deflate 목록과 해제, ZIP32/ZIP64 생성, 기본 TAR/USTAR, GZ, TAR.GZ, 비암호화 7z 해제를 지원합니다. GZ 연결 멤버는 하나의 논리 스트림으로 합칩니다. 다중 볼륨, UTF-8로 해석할 수 없는 ZIP 이름, PAX/GNU 확장과 특수 항목 해제는 미지원입니다. | |
| 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로 거부합니다. 어느 경로로 얻은 이름이든 같은 경로 안전성 검사와 충돌 검사를 거칩니다. |
| 7 | 7 | - ZIP/TAR/GZ/TAR.GZ/7z 목록과 해제는 입력 기본 한도 u64::MAX, 해제 총량 16 GiB, 항목 10,000개입니다. 요청 limits는 이 값을 낮출 수 있습니다. 64 KiB 버퍼와 임시 파일로 입력과 검증 완료 payload를 처리해 모든 출력의 CRC, 크기와 경로를 게시 전에 검사합니다. checkpoint마다 취소, 부모 프로세스 생존과 300초 한도를 확인합니다. ZIP 생성은 원본을 하나씩 스냅샷으로 읽어 스트리밍으로 압축하며 원본 크기 합계에 16 GiB 한도를 적용합니다. ZIP64 크기와 오프셋은 필요한 항목에만 기록합니다. slice 기반 archive parser는 입력 64 MiB/출력 128 MiB, slice ZIP builder는 원본 및 결과 128 MiB 한도를 유지합니다. |
| 8 | 8 | - 경로 깊이는 64개 구성 요소, 이름/출력 계획 메타데이터 예산은 8 MiB, 출력 계획 노드는 32,768개로 제한합니다. 이름 복제와 인덱스 비용을 보수적으로 계산해 할당 전에 Limit으로 거부합니다. |
| @@ -10,14 +10,14 @@ | ||
| 10 | 10 | - ListId는 열린 파일 객체, 전체 입력 SHA-256과 catalog version에 연결됩니다. 입력을 다시 읽어 검증한 전용 임시 파일 스냅샷만 해독합니다. 불일치는 출력 전 SourceChanged이며 목록을 다시 열어야 합니다. 원본의 사후 변경 감시나 파일 잠금 보장은 아닙니다. |
| 11 | 11 | - 출력 폴더는 미리 존재해야 합니다. Linux는 소유 UID가 같고 group/other 쓰기가 없는 폴더만 허용합니다. openat/O_NOFOLLOW로 디렉터리를 고정하고 새 임시 파일을 배타적으로 만든 뒤 hard link로 게시합니다. 기존 파일과 링크를 덮어쓰지 않습니다. Windows는 reparse point를 거부하고 부모 디렉터리 핸들에서 delete sharing을 제한합니다. |
| 12 | 12 | - 파일 sync/close는 게시 전에 확인합니다. 게시 후 부모 sync와 임시 파일 정리 실패는 게시 사실과 따로 보고합니다. Windows의 디렉터리 내구성은 Unconfirmed입니다. hard link의 결과가 불명확하면 CommitUncertain/Uncertain이며 자동 재시도나 rollback은 없습니다. |
| 13 | 삭제: - 생성한 디렉터리와 게시한 파일은 취소 시 유지하고 Output으로 보고합니다. 실패한 임시 파일 정리는 실제 임시 이름과 PartialRetained로 보고합니다. 임시 파일 생성과 일부 쓰기 뒤 ENOSPC 주입 시험은 Linux에서 수행합니다. close/sync/link 장애 주입과 Windows 실기 검증은 아직 수행하지 않았습니다. | |
| 13 | 추가: - 생성한 디렉터리와 게시한 파일은 취소 시 유지하고 Output으로 보고합니다. 실패한 임시 파일 정리는 실제 임시 이름과 PartialRetained로 보고합니다. 임시 파일 생성과 일부 쓰기 뒤 ENOSPC, 파일 sync와 교체 호출 실패, 게시 후 디렉터리 sync 실패 주입 시험은 Linux에서 수행합니다. close 장애 주입과 Windows 실기 검증은 아직 수행하지 않았습니다. | |
| 14 | 14 | |
| 15 | 15 | ## 스트리밍과 자원 정리 |
| 16 | 16 | |
| 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 메모리 강제 격리나 모든 아카이브의 보장을 뜻하지 않습니다. 입력 크기와 무관한 메타데이터 예산은 유지합니다. |
| @@ -35,6 +35,25 @@ revision 2의 기존 필드와 오류 tag 0~12 및 입력/출력 기본 한도 | ||
| 35 | 35 | - 합성 표본은 Python 표준 lzma로 생성합니다. 별도로 시스템 libarchive가 만든 LZMA1/LZMA2 표본을 해제하고, 합성 표본도 libarchive 읽기 API로 검사합니다. libarchive는 Linux 시험의 독립 참조 도구이며 제품 의존성이 아닙니다. 시험 도구와 표본은 tests/rust-archive-worker 아래에 있습니다. |
| 36 | 36 | - 형식 확장은 히나타 님과 합의한 Format::SevenZip=4입니다. 기존 값 0~3과 필드, 메시지 tag, 프레임 version은 유지합니다. 구버전 앱은 값 4를 거부하므로 앱 Format과 양방향 변환도 갱신해야 합니다. 이 백엔드 변경은 frontend 코드를 수정하지 않습니다. |
| 37 | 37 | |
| 38 | 추가: ## 압축 TAR 해제 | |
| 39 | 추가: | |
| 40 | 추가: TAR.BZ2와 TAR.XZ는 확장자가 아닌 BZh 및 XZ 매직으로 판별하고 비공개 임시 파일로 먼저 해제합니다. 연결된 BZip2/XZ 스트림은 하나의 TAR로 합치며 XZ의 4바이트 정렬 스트림 패딩도 허용합니다. 빈 TAR, USTAR 이름과 빈 폴더를 지원하지만 독립 BZ2/XZ 데이터 파일은 TAR가 아니면 거부합니다. | |
| 41 | 추가: | |
| 42 | 추가: 해제 총량은 TAR 헤더와 패딩을 포함해 기존 16 GiB 이하이며 요청으로 낮출 수 있습니다. 64 KiB씩 실제 해제량을 확인하고 기록 전에 임시 저장소의 공간을 검사합니다. XZ는 블록별 LZMA2 디코더 메모리 32 MiB, 인덱스 8 MiB, 스트림 수와 스트림당 블록 수 각각 32,768을 상한으로 둡니다. 이 상한을 넘는 정상 파일도 Limit로 거부합니다. 해제 전체와 TAR 경로, 항목 종류 및 이름 충돌을 검증하기 전에는 목적지에 게시하지 않습니다. 출력 공간 검사, 안전한 충돌 처리, 취소와 300초 시간 제한도 기존 흐름을 사용합니다. | |
| 43 | 추가: | |
| 44 | 추가: XZ의 헤더, 인덱스, 푸터 CRC와 역방향 크기 및 전체 선언 해제량을 확인하고 실제 해제량과 비교합니다. 각 블록의 헤더와 LZMA2 청크 경계를 따라 압축 길이와 해제량을 인덱스 레코드 및 선택적 헤더 크기와 대조하므로 다른 블록이나 연결 스트림의 크기 변조가 상쇄되어도 Integrity로 거부합니다. 지원하는 BCJ와 Delta 필터는 길이를 보존합니다. 이 사전 검사는 payload를 해제하거나 할당하지 않으며 기존 디코더가 청크 내용과 데이터 블록의 CRC32/CRC64/SHA256 검사를 수행한 뒤에만 게시합니다. [XZ 명세 4.3절](https://tukaani.org/xz/xz-file-format.txt)의 블록별 Unpadded Size와 Uncompressed Size 검사를 적용합니다. XZ의 Check=None도 형식대로 허용하므로 데이터 체크섬이 없는 파일의 내용 무결성을 보장하지 않습니다. TAR의 PAX/GNU 확장, 링크와 특수 항목의 기존 제한도 유지합니다. | |
| 45 | 추가: | |
| 46 | 추가: 통신에는 기존 Format::Tar=1을 사용합니다. 압축 방식별 새 형식 값이나 메시지 변경은 없으며 목록 식별자는 원본 객체, 길이와 SHA256을 계속 포함합니다. 화면의 파일 선택 필터와 지원 안내, 새 형식의 UI 상황 추가는 frontend 연동 범위입니다. | |
| 47 | 추가: | |
| 48 | 추가: 의존성 선택 근거는 다음과 같습니다. | |
| 49 | 추가: | |
| 50 | 추가: - [bzip2 0.6.1](https://docs.rs/crate/bzip2/0.6.1/source/Cargo.toml)은 MIT OR Apache-2.0이며 기본 백엔드가 Rust 구현인 libbz2-rs-sys입니다. 고정 lockfile은 libbz2-rs-sys 0.2.6(bzip2-1.0.6 자유 라이선스)을 선택하고 Rust 할당자를 사용합니다. C 구현인 bzip2-sys 기능과 stdio/C 할당자는 활성화하지 않습니다. | |
| 51 | 추가: - [lzma-rust2 0.25.0](https://docs.rs/lzma-rust2/latest/lzma_rust2/struct.XzReader.html)은 Apache-2.0의 Rust 구현입니다. std와 xz만 활성화해 인코더와 다중 스레드 구현을 제외하고 사전 할당 전 메모리 제한을 적용합니다. CRC와 인덱스 레코드 개수를 검증하며 연결 스트림을 끝까지 읽습니다. 레코드별 크기는 작업자가 별도로 대조합니다. | |
| 52 | 추가: - 두 라이브러리와 새 전이 의존성의 원문은 Cargo 체크섬을 대조하는 기존 packaging/licenses.py가 고지에 자동 포함합니다. tests/release-packages/test_compressed_tar_licenses.py는 실제 고지에 세 압축 라이브러리의 원문과 해시가 포함되고 C 압축 백엔드가 없는지 확인합니다. | |
| 53 | 추가: - 2026-11-13 [RUSTSEC-2023-0004](https://rustsec.org/advisories/RUSTSEC-2023-0004.html)의 bzip2 DoS 권고와 수정 범위(>=0.4.4)를 확인했습니다. 고정 lockfile의 bzip2 0.6.1은 수정 범위에 해당하므로 이 권고의 영향을 받지 않습니다. 새 전이 sha2 0.11.1은 RUSTSEC-2021-0100의 수정 범위(>=0.9.8)에 해당합니다. 전체 최신 DB 자동 감사와 취약점 부재를 보장하는 확인은 수행하지 않았습니다. | |
| 54 | 추가: | |
| 55 | 추가: Python 표준 bz2, lzma와 tarfile로 독립 생성 및 해제한 결과의 SHA256과 실제 작업자 결과를 비교합니다. tests/rust-archive-worker/compressed_tar.rs는 정상, 빈 TAR, 연결 스트림, XZ 필터와 체크 방식, 잘림과 손상, 푸터/인덱스 크기, 큰 사전, 작은 출력 한도의 압축 폭탄, 한도 경계, 경로 이탈, 링크, 목록 식별자와 선택, 취소 및 디코더 임시 공간 실패를 검증합니다. | |
| 56 | 추가: | |
| 38 | 57 | ## 암호 ZIP |
| 39 | 58 | |
| 40 | 59 | - AES는 [WinZip AE-1/AE-2 명세](https://www.winzip.com/en/support/aes-encryption/)의 method 99, 0x9901 추가 필드, PBKDF2-HMAC-SHA1 1000회, 16바이트 salt, AES-256 CTR와 HMAC-SHA1-80 형식을 사용합니다. 새 파일은 CRC를 노출하지 않는 AE-2입니다. AE-1은 인증과 CRC를 모두 검증합니다. AES-128/192와 PKWARE Strong Encryption은 미지원입니다. |
| @@ -57,15 +76,31 @@ revision 2의 기존 필드와 오류 tag 0~12 및 입력/출력 기본 한도 | ||
| 57 | 76 | |
| 58 | 77 | ## 공유 codec |
| 59 | 78 | |
| 60 | 삭제: `protocol.rs`는 요청과 이벤트 타입, `wire.rs`는 LE codec이며 비밀 값이 담긴 프레임 버퍼는 zeroize로 정리합니다. 앱은 이 라이브러리의 타입과 Reader/Writer를 사용할 수 있습니다. `contract.json`은 합의한 revision 2 원문입니다. | |
| 79 | 추가: `protocol.rs`는 요청과 이벤트 타입, `wire.rs`는 LE codec이며 비밀 값이 담긴 프레임 버퍼는 zeroize로 정리합니다. 앱은 이 라이브러리의 타입과 Reader/Writer를 사용할 수 있습니다. `contract.json`은 합의한 revision 3 원문이며 `extract_conflicts.status`에서 구현 상태를 구분합니다. | |
| 61 | 80 | |
| 62 | 81 | 헤더는 ZAW1, version u16=1, kind u16, body length u32, reserved u32=0, job ID u64, sequence u64의 32바이트입니다. 양방향 sequence는 각각 0부터 시작합니다. body는 최대 1 MiB이며 한 방향당 최대 1,000,000프레임입니다. 잘린 프레임, 알 수 없는 tag, 잔여 payload, 잘못된 ID/sequence를 거부합니다. |
| 63 | 82 | |
| 64 | 삭제: - kind: Start=1, Password=2, Cancel=3, Accepted=100, Entry=101, ListEnd=102, PasswordRequired=103, Progress=104, Output=105, Terminal=106, CancelAck=107입니다. | |
| 83 | 추가: - kind: Start=1, Password=2, Cancel=3, StartInteractive=4, ConflictReply=5, Accepted=100, Entry=101, ListEnd=102, PasswordRequired=103, Progress=104, Output=105, Terminal=106, CancelAck=107, ConflictRequired=108, ConflictResolved=109입니다. 새 kind의 런타임 지원 상태는 아래 revision 3 절을 따릅니다. | |
| 65 | 84 | - body 필드는 `protocol.rs` 선언 순서입니다. enum은 선언 순서의 u8 tag이며 NativePath/SourceObject만 Unix=1, Windows=2입니다. bool/Option은 0 또는 1입니다. String/Vec는 u32 길이 뒤 원소를 저장하며 String은 UTF-8 바이트 길이입니다. `[u8; N]`은 길이 없이 N바이트입니다. action variant의 필드는 선언 순서를 사용합니다. Start는 action 뒤 limits(input u64, output u64, entries u32)입니다. |
| 66 | 85 | - Password의 비밀 값은 Debug에 노출되지 않습니다. 암호 작업은 PasswordRequired의 challenge_id와 일치하는 Password를 한 번 받습니다. 오래된 ID, 중복 또는 요청 전 암호는 Protocol 오류입니다. 비밀 값은 로그나 파일에 저장하지 않습니다. |
| 67 | 86 | - CancelAck.request_sequence는 요청 헤더 sequence입니다. Requested, AlreadyRequested, TooLate, Finished는 최종 결과와 별개입니다. 종료와 경합한 요청은 읽히지 않아 응답이 없을 수 있습니다. Terminal은 마지막 프레임이며 Failed/Cancelled도 정상 전달 뒤 프로세스 exit=0입니다. 앱은 Terminal과 stdout/stderr EOF, child wait를 모두 확인해야 합니다. |
| 68 | 87 | |
| 88 | 추가: ## revision 3 충돌 계약 | |
| 89 | 추가: | |
| 90 | 추가: 작업자는 `StartInteractive`로 시작한 압축 해제에서 덮어쓰기, 건너뛰기와 이름 바꿔 저장을 처리합니다. 기존 `Start`는 이름 충돌 시 중단합니다. 앱의 활성화와 실제 UI 연동은 별도 PR에서 검증합니다. | |
| 91 | 추가: | |
| 92 | 추가: - `StartInteractive(Start)`는 kind 4이며 기존 Start body를 그대로 사용합니다. Extract만 허용하고 List와 CreateZip은 codec에서 거부합니다. 기존 Start=1의 충돌 시 중단 동작과 모든 기존 필드 및 tag는 유지하며 구버전 작업자로 자동 재시도하지 않습니다. | |
| 93 | 추가: - `ConflictChoice`는 Overwrite=0, Skip=1, Rename=2입니다. `ConflictReply`(5)는 challenge_id u64, choice u8, apply_to_remaining bool 순서입니다. | |
| 94 | 추가: - `ConflictRequired`(108)는 challenge_id u64, entry_id u32, relative_name String, incoming_size u64, existing_size u64 순서입니다. 일반 파일끼리의 충돌에 세 선택을 허용하며 폴더끼리는 합치고 파일과 폴더 충돌 및 링크는 차단합니다. | |
| 95 | 추가: - `ConflictResolved`(109)는 entry_id u32, relative_name String, choice u8 순서입니다. 일괄 적용에도 항목마다 보내며 저장 성공을 뜻하지 않습니다. 교체와 이름 변경의 게시 성공은 기존 `Output::Created`로 별도 확인하고 건너뛰기에는 Created를 보내지 않습니다. | |
| 96 | 추가: - Rename 이름은 작업자가 같은 폴더 안에서 `파일명 (1).확장자` 형태의 미사용 번호 이름으로 정합니다. 기존 이름과 뒤에 처리할 항목의 경로도 피하며, 긴 이름은 UTF-8 경계를 보존해 255바이트 안으로 줄입니다. 일괄 적용은 현재 작업의 남은 일반 파일 충돌에만 적용합니다. 질문은 한 번에 하나이며 잘못되거나 중복된 응답은 Protocol, 답변 전 EOF도 Protocol입니다. 취소를 처리하고 기존 300초 제한에 대기 시간을 포함합니다. | |
| 97 | 추가: - 전부 건너뛰고 새 출력도 없으면 Completed, Publication::None, created_count=0, Durability::NotApplicable입니다. 새 폴더가 만들어졌다면 해당 Output과 실제 집계를 유지합니다. 교체는 created_count에 포함하며 건너뛰기는 제외합니다. | |
| 98 | 추가: - 런타임은 전체 무결성 검증 후 질문하고 목적지 임시 파일 기록, 검증, sync와 close를 마친 뒤 교체합니다. 교체 전 실패에는 원본을 보존하고 교체 후 오류에는 실제 게시, 내구성과 정리 상태를 보고합니다. 전체 작업의 원상 복구를 약속하지 않습니다. | |
| 99 | 추가: | |
| 100 | 추가: 덮어쓰기 직전에 기존 파일과 부모의 식별자, 크기와 수정 시각을 다시 비교하며 변경이 감지되면 Conflict로 중단합니다. Linux에서는 고정 부모의 renameat, Windows에서는 같은 폴더의 MoveFileExW(REPLACE_EXISTING)를 사용하며 원본을 먼저 지우지 않습니다. 기존 파일의 다른 hard link는 수정하지 않습니다. 같은 계정의 동시 수정과 검사 직후 경합을 원자적으로 비교하거나 전체 작업을 되돌리는 기능은 아닙니다. Windows의 폴더 내구성은 기존처럼 Unconfirmed이며 전원 차단 뒤 복구를 보장하지 않습니다. | |
| 101 | 추가: | |
| 102 | 추가: 교체 동작의 근거는 [Linux rename](https://man7.org/linux/man-pages/man2/rename.2.html)과 [Microsoft MoveFileExW](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexw)입니다. | |
| 103 | 추가: | |
| 69 | 104 | ## 검증과 의존성 |
| 70 | 105 | |
| 71 | 106 | 시험은 `tests/rust-archive-worker`에 있습니다. Python 표준 라이브러리로 만든 ZIP/TAR/GZ fixture와 실제 자식 프로세스를 사용합니다. 전체 검증 명령은 저장소 루트의 `python3 tests/ci/run_rust.py local`입니다. Windows 교차 빌드는 실제 Windows 실행 검증을 대신하지 않습니다. |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | { |
| 2 | 삭제: "status": "implemented-streaming-runtime", | |
| 2 | 추가: "status": "revision-3-worker-implemented", | |
| 3 | 3 | "version": 1, |
| 4 | 4 | "scope": "One job per separately spawned Rust worker; shared binary codec. Process separation is not an OS sandbox.", |
| 5 | 5 | "frame": { |
| @@ -28,7 +28,9 @@ | ||
| 28 | 28 | "commands": { |
| 29 | 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.", |
| 30 | 30 | "Password": "Matching outstanding challenge_id:u64 and max1024 UTF-8 bytes; never log, Debug, echo or persist secrets.", |
| 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." | |
| 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 | 추가: "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.", | |
| 33 | 추가: "ConflictReply": "Kind 5: challenge_id:u64, choice:ConflictChoice(u8), apply_to_remaining:bool. Match the one outstanding conflict challenge exactly once. Applying to remaining affects only later regular-file conflicts in this job." | |
| 32 | 34 | }, |
| 33 | 35 | "events": { |
| 34 | 36 | "Accepted": "Action and capabilities; encryption capability is true for implemented ZipCrypto extraction and WinZip AES-256 extraction/creation.", |
| @@ -55,10 +57,12 @@ | ||
| 55 | 57 | "TooLate": "Final job completion/commit decision has been sealed so cancellation can no longer influence the outcome; final outcome may still be Failed or publication Uncertain. Previously created entries alone do not make a multi-entry job TooLate.", |
| 56 | 58 | "Finished": "Business outcome has already been fixed, but Terminal has not yet been emitted. Does not establish success, EOF, child exit or reaping.", |
| 57 | 59 | "ordering": "Each well-formed Cancel consumed before Terminal is acknowledged once before Terminal. Terminal is the last worker protocol frame. A Cancel racing with Terminal/exit may remain unread and have no acknowledgement; app uses Terminal plus EOF and wait, never synthesizes a worker acknowledgement or successful cancellation." |
| 58 | 삭제: } | |
| 60 | 추가: }, | |
| 61 | 추가: "ConflictRequired": "Kind 108: challenge_id:u64, entry_id:u32, relative_name:UTF8, incoming_size:u64, existing_size:u64. One ordinary-file conflict at a time, after complete archive integrity validation. All three choices are permitted; links and file/directory type conflicts remain rejected.", | |
| 62 | 추가: "ConflictResolved": "Kind 109: entry_id:u32, relative_name:UTF8, choice:ConflictChoice(u8). Emit for every resolved conflict, including automatically applied choices. This records the action and resolved name, not successful publication; successful overwrite or rename also requires Output Created. Skip emits no Output Created." | |
| 59 | 63 | }, |
| 60 | 64 | "lifecycle": [ |
| 61 | 삭제: "Start once; no automatic retry or overwrite. Password/Cancel remain readable during work.", | |
| 65 | 추가: "Exactly one Start or StartInteractive; no automatic retry or fallback. Password/Cancel remain readable during work. ConflictReply is accepted only for a matching outstanding interactive conflict.", | |
| 62 | 66 | "Parent drains both streams concurrently. Stdout is protocol only; stderr is bounded diagnostics without secrets.", |
| 63 | 67 | "Exactly one Terminal ends business results and is the final worker protocol frame; CancelAck can precede but never follow it. Worker exits0 after delivered terminal, including Failed/Cancelled. Malformed protocol or crash can exit nonzero without terminal.", |
| 64 | 68 | "App requires matching terminal, stdout/stderr EOF and owned child wait/exit before replacement/close. EOF/exit0 alone is not success.", |
| @@ -69,7 +73,7 @@ | ||
| 69 | 73 | "safe_output": [ |
| 70 | 74 | "Reject absolute/dotdot/drive/UNC/device/reserved/alternate-stream names and case/path collisions before writes.", |
| 71 | 75 | "Reject archive links/special entries on extraction. Do not follow output parent symlinks/reparse points.", |
| 72 | 삭제: "Create output files exclusively; never truncate or write pre-existing files. GZip FNAME does not choose destination.", | |
| 76 | 추가: "Legacy Start creates output files exclusively and never truncates or writes pre-existing files. StartInteractive may replace an existing ordinary file only after the agreed choice and complete temporary output validation. GZip FNAME does not choose destination.", | |
| 73 | 77 | "CRC/size/stream-end validation precedes committed output events; preserve commit/durability/cleanup distinctions." |
| 74 | 78 | ], |
| 75 | 79 | "pending": [ |
| @@ -81,12 +85,18 @@ | ||
| 81 | 85 | "implementation_verified": false, |
| 82 | 86 | "policy": "Human approved pure Rust RustCrypto under MIT/Apache. No home-grown AES or password KDF; approval alone does not enable encryption capability." |
| 83 | 87 | }, |
| 84 | 삭제: "revision": 2, | |
| 88 | 추가: "revision": 3, | |
| 85 | 89 | "coordination": { |
| 86 | 90 | "frontend_message_id": "41a0e5a5-27d0-437f-805d-d39313082096", |
| 87 | 91 | "basis": "Revision 2 list identity, explicit raw GZip output naming and cancellation acknowledgement are implemented. Field order and tags remain unchanged.", |
| 88 | 92 | "streaming_frontend_message_id": "59142fd4-22d3-4dc5-a875-5347e1b054da", |
| 89 | 삭제: "disk_full_frontend_message_id": "3b01f4c4-c9b4-4c72-a9a0-b3df39979ea1" | |
| 93 | 추가: "disk_full_frontend_message_id": "3b01f4c4-c9b4-4c72-a9a0-b3df39979ea1", | |
| 94 | 추가: "conflict_frontend_message_ids": [ | |
| 95 | 추가: "37815dda-3271-4f83-be4d-8da1a6e0c2ab", | |
| 96 | 추가: "87ff39f9-f7fe-4efc-bd2e-d73ab3246356" | |
| 97 | 추가: ], | |
| 98 | 추가: "conflict_backend_message_id": "64e29128-e8a2-45e5-8577-db84a66feaa9", | |
| 99 | 추가: "revision_3_status": "Joint agreement complete. Types, codec and interactive worker runtime implemented; frontend activation and native UI integration remain separate." | |
| 90 | 100 | }, |
| 91 | 101 | "list_identity": { |
| 92 | 102 | "ListId": { |
| @@ -114,7 +124,7 @@ | ||
| 114 | 124 | "gzip_output_name": "Required Some(nonempty validated UTF-8 single leaf filename) for raw GZIP extraction, for both All and EntryIds. Reject absolute/drive/UNC/device/alternate-stream/reserved names, separators, dot/dotdot and invalid leaf names before creating outputs. Missing/invalid value returns InvalidRequest; no implicit basename or FNAME fallback.", |
| 115 | 125 | "other_formats": "Must be None for ZIP, TAR and TAR_GZIP; reject Some as InvalidRequest rather than silently ignoring it. TAR_GZIP uses validated inner TAR member names.", |
| 116 | 126 | "gzip_catalog": "Raw GZIP is one logical stream entry with entry_id0. Its listed display name is not an output path; entry selection still requires ListId.", |
| 117 | 삭제: "publication": "Resolve the supplied leaf under destination using the same no-follow and exclusive-create guards. Existing destination files return Conflict; never overwrite, rename to an automatic alternative or retry." | |
| 127 | 추가: "publication": "Resolve the supplied leaf under destination using the same no-follow guards. Existing destination files return Conflict for legacy Start. StartInteractive follows the regular-file conflict policy; never automatically downgrade or retry through legacy Start." | |
| 118 | 128 | }, |
| 119 | 129 | "design_references": [ |
| 120 | 130 | { |
| @@ -156,7 +166,7 @@ | ||
| 156 | 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.", |
| 157 | 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.", |
| 158 | 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.", |
| 159 | 삭제: "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.", | |
| 160 | 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.", |
| 161 | 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.", |
| 162 | 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." |
| @@ -192,5 +202,25 @@ | ||
| 192 | 202 | "limits": "All expanded file and directory entries count toward entries (default 10000). Only file logical bytes count toward min(input,output), default output 16 GiB. Preserve 8 MiB metadata and 64-component name limits. Validate the complete plan and case-insensitive/path-prefix conflicts before requesting a password.", |
| 193 | 203 | "consistency": "Capture each file from its validated open handle. Compare planned object identity, kind, size and modification time before capture and check planned objects again before publishing the completed ZIP; detected changes fail SourceChanged. This is not an atomic snapshot of an entire directory tree.", |
| 194 | 204 | "encryption": "AES-256 protects file contents using the existing AE-2 encoding. Directory entries are stored as zero-byte unencrypted directory records; entry names remain visible, as with other ZIP entries." |
| 205 | 추가: }, | |
| 206 | 추가: "conflict_choice_tags": { | |
| 207 | 추가: "Overwrite": 0, | |
| 208 | 추가: "Skip": 1, | |
| 209 | 추가: "Rename": 2 | |
| 210 | 추가: }, | |
| 211 | 추가: "extract_conflicts": { | |
| 212 | 추가: "status": "worker-implemented", | |
| 213 | 추가: "compatibility": "Preserve frame version 1, every existing message kind, field order and enum tag. Add StartInteractive=4, ConflictReply=5, ConflictRequired=108 and ConflictResolved=109. Older workers reject kind 4 before output. Do not automatically retry, overwrite or fall back.", | |
| 214 | 추가: "legacy": "Start keeps its existing abort-on-conflict behavior. List and CreateZip never accept interactive conflict mode. Existing limits, source identity, integrity checks and path guards remain mandatory.", | |
| 215 | 추가: "scope": "Only ordinary-file/ordinary-file collisions. Merge existing directories as before; reject file/directory type collisions, symbolic links, reparse points and other special entries. Complete integrity validation of the entire catalog precedes conflict questions and destination publication.", | |
| 216 | 추가: "rename": "Worker selects an unused numbered sibling in the same directory under the validated output root. The app never supplies an arbitrary replacement path. Revalidate the chosen destination before publication. Avoid all selected archive output paths and prior generated names. Preserve UTF-8 boundaries when shortening a leaf to 255 bytes; try at most 10000 numbered candidates.", | |
| 217 | 추가: "wait": "At most one outstanding conflict or password challenge. Reject premature, stale or duplicate replies with Protocol. Cancel remains readable during a conflict wait. EOF without a reply fails Protocol; the existing 300-second job duration includes waits.", | |
| 218 | 추가: "apply_to_remaining": "Keep the chosen policy only for the remaining ordinary-file conflicts in this job. Emit ConflictResolved for every such entry even without another question. Never carry the policy to another job or a file/directory or link collision.", | |
| 219 | 추가: "events": "ConflictResolved reports an action and resolved relative name, not storage success. For overwrite and rename, Output Created separately confirms publication; skip has no Created output. On later errors preserve publication, durability and cleanup distinctions.", | |
| 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 | 추가: "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 | 추가: "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.", | |
| 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." | |
| 195 | 225 | } |
| 196 | 226 | } |
| @@ -0,0 +1,367 @@ | ||
| 1 | 추가: use crate::{protocol::ErrorCode, space, spool}; | |
| 2 | 추가: use std::{ | |
| 3 | 추가: cell::RefCell, | |
| 4 | 추가: fs::File, | |
| 5 | 추가: io::{self, BufReader, Read, Seek, Write}, | |
| 6 | 추가: }; | |
| 7 | 추가: use zeroize::Zeroizing; | |
| 8 | 추가: | |
| 9 | 추가: type Result<T> = std::result::Result<T, ErrorCode>; | |
| 10 | 추가: const CHUNK: usize = 65_536; | |
| 11 | 추가: const XZ_MEMORY_KIB: u32 = 32 * 1024; | |
| 12 | 추가: | |
| 13 | 추가: #[derive(Clone, Copy)] | |
| 14 | 추가: pub(crate) enum Compression { | |
| 15 | 추가: Bzip2, | |
| 16 | 추가: Xz, | |
| 17 | 추가: } | |
| 18 | 추가: | |
| 19 | 추가: #[derive(Debug)] | |
| 20 | 추가: struct InputError(ErrorCode); | |
| 21 | 추가: | |
| 22 | 추가: impl std::fmt::Display for InputError { | |
| 23 | 추가: fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | |
| 24 | 추가: write!(formatter, "{:?}", self.0) | |
| 25 | 추가: } | |
| 26 | 추가: } | |
| 27 | 추가: | |
| 28 | 추가: impl std::error::Error for InputError {} | |
| 29 | 추가: | |
| 30 | 추가: struct CheckedInput<'a, F> { | |
| 31 | 추가: file: &'a mut File, | |
| 32 | 추가: check: &'a RefCell<&'a mut F>, | |
| 33 | 추가: } | |
| 34 | 추가: | |
| 35 | 추가: impl<F: FnMut() -> Result<()>> Read for CheckedInput<'_, F> { | |
| 36 | 추가: fn read(&mut self, buffer: &mut [u8]) -> io::Result<usize> { | |
| 37 | 추가: (self.check.borrow_mut())().map_err(|error| io::Error::other(InputError(error)))?; | |
| 38 | 추가: let count = buffer.len().min(CHUNK); | |
| 39 | 추가: self.file | |
| 40 | 추가: .read(&mut buffer[..count]) | |
| 41 | 추가: .map_err(|_| io::Error::other(InputError(ErrorCode::Io))) | |
| 42 | 추가: } | |
| 43 | 추가: } | |
| 44 | 추가: | |
| 45 | 추가: fn decode_error(error: io::Error) -> ErrorCode { | |
| 46 | 추가: if let Some(error) = error | |
| 47 | 추가: .get_ref() | |
| 48 | 추가: .and_then(|error| error.downcast_ref::<InputError>()) | |
| 49 | 추가: { | |
| 50 | 추가: return error.0; | |
| 51 | 추가: } | |
| 52 | 추가: match error.kind() { | |
| 53 | 추가: io::ErrorKind::OutOfMemory => ErrorCode::Limit, | |
| 54 | 추가: io::ErrorKind::Unsupported => ErrorCode::UnsupportedFeature, | |
| 55 | 추가: _ => ErrorCode::Integrity, | |
| 56 | 추가: } | |
| 57 | 추가: } | |
| 58 | 추가: | |
| 59 | 추가: pub(crate) fn decode( | |
| 60 | 추가: source: &mut File, | |
| 61 | 추가: compression: Compression, | |
| 62 | 추가: limit: u64, | |
| 63 | 추가: check: &mut impl FnMut() -> Result<()>, | |
| 64 | 추가: ) -> Result<(File, u64)> { | |
| 65 | 추가: check()?; | |
| 66 | 추가: let expected = if matches!(compression, Compression::Xz) { | |
| 67 | 추가: Some(xz_layout(source, limit, check)?) | |
| 68 | 추가: } else { | |
| 69 | 추가: None | |
| 70 | 추가: }; | |
| 71 | 추가: source.rewind().map_err(space::io_error)?; | |
| 72 | 추가: let mut output = spool::temporary()?; | |
| 73 | 추가: let check = RefCell::new(check); | |
| 74 | 추가: let input = CheckedInput { | |
| 75 | 추가: file: source, | |
| 76 | 추가: check: &check, | |
| 77 | 추가: }; | |
| 78 | 추가: let mut reader: Box<dyn Read + '_> = match compression { | |
| 79 | 추가: Compression::Bzip2 => Box::new(bzip2::bufread::MultiBzDecoder::new( | |
| 80 | 추가: BufReader::with_capacity(CHUNK, input), | |
| 81 | 추가: )), | |
| 82 | 추가: Compression::Xz => Box::new(lzma_rust2::XzReader::new_mem_limit( | |
| 83 | 추가: input, | |
| 84 | 추가: true, | |
| 85 | 추가: XZ_MEMORY_KIB, | |
| 86 | 추가: )), | |
| 87 | 추가: }; | |
| 88 | 추가: let mut buffer = Zeroizing::new([0; CHUNK]); | |
| 89 | 추가: let mut total = 0u64; | |
| 90 | 추가: loop { | |
| 91 | 추가: (check.borrow_mut())()?; | |
| 92 | 추가: let count = reader.read(&mut buffer[..]).map_err(decode_error)?; | |
| 93 | 추가: if count == 0 { | |
| 94 | 추가: break; | |
| 95 | 추가: } | |
| 96 | 추가: total = total | |
| 97 | 추가: .checked_add(count as u64) | |
| 98 | 추가: .filter(|total| *total <= limit) | |
| 99 | 추가: .ok_or(ErrorCode::Limit)?; | |
| 100 | 추가: // 전체 검증 전에는 비공개 임시 파일에만 기록함. | |
| 101 | 추가: space::ensure(&output, count as u64)?; | |
| 102 | 추가: output | |
| 103 | 추가: .write_all(&buffer[..count]) | |
| 104 | 추가: .map_err(space::io_error)?; | |
| 105 | 추가: } | |
| 106 | 추가: (check.borrow_mut())()?; | |
| 107 | 추가: if expected.is_some_and(|expected| expected != total) { | |
| 108 | 추가: return Err(ErrorCode::Integrity); | |
| 109 | 추가: } | |
| 110 | 추가: Ok((output, total)) | |
| 111 | 추가: } | |
| 112 | 추가: | |
| 113 | 추가: fn read_at( | |
| 114 | 추가: source: &mut File, | |
| 115 | 추가: offset: u64, | |
| 116 | 추가: bytes: &mut [u8], | |
| 117 | 추가: check: &mut impl FnMut() -> Result<()>, | |
| 118 | 추가: ) -> Result<()> { | |
| 119 | 추가: check()?; | |
| 120 | 추가: source | |
| 121 | 추가: .seek(std::io::SeekFrom::Start(offset)) | |
| 122 | 추가: .map_err(space::io_error)?; | |
| 123 | 추가: source.read_exact(bytes).map_err(|error| { | |
| 124 | 추가: if error.kind() == io::ErrorKind::UnexpectedEof { | |
| 125 | 추가: ErrorCode::Integrity | |
| 126 | 추가: } else { | |
| 127 | 추가: ErrorCode::Io | |
| 128 | 추가: } | |
| 129 | 추가: }) | |
| 130 | 추가: } | |
| 131 | 추가: | |
| 132 | 추가: fn vli(bytes: &[u8], cursor: &mut usize) -> Result<u64> { | |
| 133 | 추가: let mut value = 0u64; | |
| 134 | 추가: for shift in (0..63).step_by(7) { | |
| 135 | 추가: let byte = *bytes.get(*cursor).ok_or(ErrorCode::Integrity)?; | |
| 136 | 추가: *cursor += 1; | |
| 137 | 추가: value |= u64::from(byte & 127) << shift; | |
| 138 | 추가: if byte & 128 == 0 { | |
| 139 | 추가: if shift != 0 && byte == 0 { | |
| 140 | 추가: return Err(ErrorCode::Integrity); | |
| 141 | 추가: } | |
| 142 | 추가: return Ok(value); | |
| 143 | 추가: } | |
| 144 | 추가: } | |
| 145 | 추가: Err(ErrorCode::Integrity) | |
| 146 | 추가: } | |
| 147 | 추가: | |
| 148 | 추가: fn lzma2_size( | |
| 149 | 추가: source: &mut File, | |
| 150 | 추가: mut at: u64, | |
| 151 | 추가: end: u64, | |
| 152 | 추가: expected: u64, | |
| 153 | 추가: check: &mut impl FnMut() -> Result<()>, | |
| 154 | 추가: ) -> Result<()> { | |
| 155 | 추가: let mut size = 0u64; | |
| 156 | 추가: while at < end { | |
| 157 | 추가: let mut control = [0]; | |
| 158 | 추가: read_at(source, at, &mut control, check)?; | |
| 159 | 추가: at += 1; | |
| 160 | 추가: if control[0] == 0 { | |
| 161 | 추가: return if at == end && size == expected { | |
| 162 | 추가: Ok(()) | |
| 163 | 추가: } else { | |
| 164 | 추가: Err(ErrorCode::Integrity) | |
| 165 | 추가: }; | |
| 166 | 추가: } | |
| 167 | 추가: let header_len = match control[0] { | |
| 168 | 추가: 1 | 2 => 2, | |
| 169 | 추가: 128..=255 => 4 + usize::from(control[0] >= 192), | |
| 170 | 추가: _ => return Err(ErrorCode::Integrity), | |
| 171 | 추가: }; | |
| 172 | 추가: if end - at < header_len as u64 { | |
| 173 | 추가: return Err(ErrorCode::Integrity); | |
| 174 | 추가: } | |
| 175 | 추가: let mut header = [0; 5]; | |
| 176 | 추가: read_at(source, at, &mut header[..header_len], check)?; | |
| 177 | 추가: at += header_len as u64; | |
| 178 | 추가: let unpacked = u64::from(u16::from_be_bytes(header[..2].try_into().unwrap())) + 1; | |
| 179 | 추가: let (packed, unpacked) = if control[0] >= 128 { | |
| 180 | 추가: ( | |
| 181 | 추가: u64::from(u16::from_be_bytes(header[2..4].try_into().unwrap())) + 1, | |
| 182 | 추가: (u64::from(control[0] & 31) << 16) + unpacked, | |
| 183 | 추가: ) | |
| 184 | 추가: } else { | |
| 185 | 추가: (unpacked, unpacked) | |
| 186 | 추가: }; | |
| 187 | 추가: at = at | |
| 188 | 추가: .checked_add(packed) | |
| 189 | 추가: .filter(|at| *at <= end) | |
| 190 | 추가: .ok_or(ErrorCode::Integrity)?; | |
| 191 | 추가: size = size | |
| 192 | 추가: .checked_add(unpacked) | |
| 193 | 추가: .filter(|size| *size <= expected) | |
| 194 | 추가: .ok_or(ErrorCode::Integrity)?; | |
| 195 | 추가: } | |
| 196 | 추가: Err(ErrorCode::Integrity) | |
| 197 | 추가: } | |
| 198 | 추가: | |
| 199 | 추가: fn xz_block( | |
| 200 | 추가: source: &mut File, | |
| 201 | 추가: start: u64, | |
| 202 | 추가: unpadded: u64, | |
| 203 | 추가: size: u64, | |
| 204 | 추가: check_size: u64, | |
| 205 | 추가: check: &mut impl FnMut() -> Result<()>, | |
| 206 | 추가: ) -> Result<()> { | |
| 207 | 추가: let mut header = [0; 1024]; | |
| 208 | 추가: read_at(source, start, &mut header[..1], check)?; | |
| 209 | 추가: if header[0] == 0 { | |
| 210 | 추가: return Err(ErrorCode::Integrity); | |
| 211 | 추가: } | |
| 212 | 추가: let header_len = (usize::from(header[0]) + 1) * 4; | |
| 213 | 추가: let packed = unpadded | |
| 214 | 추가: .checked_sub(header_len as u64 + check_size) | |
| 215 | 추가: .filter(|packed| *packed != 0) | |
| 216 | 추가: .ok_or(ErrorCode::Integrity)?; | |
| 217 | 추가: read_at(source, start, &mut header[..header_len], check)?; | |
| 218 | 추가: let data = &header[..header_len - 4]; | |
| 219 | 추가: if zlib_rs::crc32::crc32(0, data) | |
| 220 | 추가: != u32::from_le_bytes(header[header_len - 4..header_len].try_into().unwrap()) | |
| 221 | 추가: { | |
| 222 | 추가: return Err(ErrorCode::Integrity); | |
| 223 | 추가: } | |
| 224 | 추가: let flags = header[1]; | |
| 225 | 추가: if flags & 0x3c != 0 { | |
| 226 | 추가: return Err(ErrorCode::UnsupportedFeature); | |
| 227 | 추가: } | |
| 228 | 추가: let mut cursor = 2; | |
| 229 | 추가: if flags & 0x40 != 0 && vli(data, &mut cursor)? != packed { | |
| 230 | 추가: return Err(ErrorCode::Integrity); | |
| 231 | 추가: } | |
| 232 | 추가: if flags & 0x80 != 0 && vli(data, &mut cursor)? != size { | |
| 233 | 추가: return Err(ErrorCode::Integrity); | |
| 234 | 추가: } | |
| 235 | 추가: let filters = usize::from(flags & 3) + 1; | |
| 236 | 추가: for number in 0..filters { | |
| 237 | 추가: let id = vli(data, &mut cursor)?; | |
| 238 | 추가: // 지원 필터는 길이를 보존하며 마지막 필터는 LZMA2임. | |
| 239 | 추가: let supported = if number + 1 == filters { | |
| 240 | 추가: id == 0x21 | |
| 241 | 추가: } else { | |
| 242 | 추가: (0x03..=0x0b).contains(&id) | |
| 243 | 추가: }; | |
| 244 | 추가: if !supported { | |
| 245 | 추가: return Err(ErrorCode::UnsupportedFeature); | |
| 246 | 추가: } | |
| 247 | 추가: let properties = vli(data, &mut cursor)?; | |
| 248 | 추가: cursor = cursor | |
| 249 | 추가: .checked_add(usize::try_from(properties).map_err(|_| ErrorCode::Integrity)?) | |
| 250 | 추가: .filter(|cursor| *cursor <= data.len()) | |
| 251 | 추가: .ok_or(ErrorCode::Integrity)?; | |
| 252 | 추가: } | |
| 253 | 추가: if data[cursor..].iter().any(|byte| *byte != 0) { | |
| 254 | 추가: return Err(ErrorCode::Integrity); | |
| 255 | 추가: } | |
| 256 | 추가: let data_start = start | |
| 257 | 추가: .checked_add(header_len as u64) | |
| 258 | 추가: .ok_or(ErrorCode::Integrity)?; | |
| 259 | 추가: let data_end = data_start.checked_add(packed).ok_or(ErrorCode::Integrity)?; | |
| 260 | 추가: // 청크 경계와 해제량을 블록별로 대조한 뒤 기존 디코더가 내용과 체크섬을 검증함. | |
| 261 | 추가: lzma2_size(source, data_start, data_end, size, check) | |
| 262 | 추가: } | |
| 263 | 추가: | |
| 264 | 추가: // 역방향 인덱스 검사는 디코더의 할당과 실제 해제량 검사보다 먼저 수행함. | |
| 265 | 추가: fn xz_layout(source: &mut File, limit: u64, check: &mut impl FnMut() -> Result<()>) -> Result<u64> { | |
| 266 | 추가: use zlib_rs::crc32::crc32; | |
| 267 | 추가: let mut end = source.metadata().map_err(space::io_error)?.len(); | |
| 268 | 추가: let mut total = 0u64; | |
| 269 | 추가: let mut streams = 0usize; | |
| 270 | 추가: while end != 0 { | |
| 271 | 추가: let mut tail = [0; 4]; | |
| 272 | 추가: loop { | |
| 273 | 추가: let at = end.checked_sub(4).ok_or(ErrorCode::Integrity)?; | |
| 274 | 추가: read_at(source, at, &mut tail, check)?; | |
| 275 | 추가: if tail != [0; 4] { | |
| 276 | 추가: break; | |
| 277 | 추가: } | |
| 278 | 추가: end = at; | |
| 279 | 추가: } | |
| 280 | 추가: streams += 1; | |
| 281 | 추가: if streams > crate::archive::MAX_OUTPUT_NODES { | |
| 282 | 추가: return Err(ErrorCode::Limit); | |
| 283 | 추가: } | |
| 284 | 추가: let footer_at = end.checked_sub(12).ok_or(ErrorCode::Integrity)?; | |
| 285 | 추가: let mut footer = [0; 12]; | |
| 286 | 추가: read_at(source, footer_at, &mut footer, check)?; | |
| 287 | 추가: if &footer[10..] != b"YZ" | |
| 288 | 추가: || crc32(0, &footer[4..10]) != u32::from_le_bytes(footer[..4].try_into().unwrap()) | |
| 289 | 추가: { | |
| 290 | 추가: return Err(ErrorCode::Integrity); | |
| 291 | 추가: } | |
| 292 | 추가: let index_len = (u64::from(u32::from_le_bytes(footer[4..8].try_into().unwrap())) + 1) * 4; | |
| 293 | 추가: if index_len > crate::archive::MAX_METADATA_BYTES as u64 { | |
| 294 | 추가: return Err(ErrorCode::Limit); | |
| 295 | 추가: } | |
| 296 | 추가: if index_len < 8 { | |
| 297 | 추가: return Err(ErrorCode::Integrity); | |
| 298 | 추가: } | |
| 299 | 추가: let index_at = footer_at | |
| 300 | 추가: .checked_sub(index_len) | |
| 301 | 추가: .ok_or(ErrorCode::Integrity)?; | |
| 302 | 추가: let mut index = vec![0; index_len as usize]; | |
| 303 | 추가: read_at(source, index_at, &mut index, check)?; | |
| 304 | 추가: let data_end = index.len() - 4; | |
| 305 | 추가: if index[0] != 0 | |
| 306 | 추가: || crc32(0, &index[..data_end]) | |
| 307 | 추가: != u32::from_le_bytes(index[data_end..].try_into().unwrap()) | |
| 308 | 추가: { | |
| 309 | 추가: return Err(ErrorCode::Integrity); | |
| 310 | 추가: } | |
| 311 | 추가: let mut cursor = 1; | |
| 312 | 추가: let count = vli(&index[..data_end], &mut cursor)?; | |
| 313 | 추가: if count > crate::archive::MAX_OUTPUT_NODES as u64 { | |
| 314 | 추가: return Err(ErrorCode::Limit); | |
| 315 | 추가: } | |
| 316 | 추가: let mut blocks = 0u64; | |
| 317 | 추가: let mut records = Vec::new(); | |
| 318 | 추가: for _ in 0..count { | |
| 319 | 추가: check()?; | |
| 320 | 추가: let unpadded = vli(&index[..data_end], &mut cursor)?; | |
| 321 | 추가: let size = vli(&index[..data_end], &mut cursor)?; | |
| 322 | 추가: if unpadded == 0 { | |
| 323 | 추가: return Err(ErrorCode::Integrity); | |
| 324 | 추가: } | |
| 325 | 추가: blocks = blocks | |
| 326 | 추가: .checked_add(unpadded.checked_add(3).ok_or(ErrorCode::Integrity)? & !3) | |
| 327 | 추가: .ok_or(ErrorCode::Integrity)?; | |
| 328 | 추가: total = total | |
| 329 | 추가: .checked_add(size) | |
| 330 | 추가: .filter(|total| *total <= limit) | |
| 331 | 추가: .ok_or(ErrorCode::Limit)?; | |
| 332 | 추가: records.push((unpadded, size)); | |
| 333 | 추가: } | |
| 334 | 추가: if data_end - cursor > 3 || index[cursor..data_end].iter().any(|byte| *byte != 0) { | |
| 335 | 추가: return Err(ErrorCode::Integrity); | |
| 336 | 추가: } | |
| 337 | 추가: let start = index_at | |
| 338 | 추가: .checked_sub(blocks) | |
| 339 | 추가: .and_then(|at| at.checked_sub(12)) | |
| 340 | 추가: .ok_or(ErrorCode::Integrity)?; | |
| 341 | 추가: let mut header = [0; 12]; | |
| 342 | 추가: read_at(source, start, &mut header, check)?; | |
| 343 | 추가: if &header[..6] != b"\xfd7zXZ\0" | |
| 344 | 추가: || header[6..8] != footer[8..10] | |
| 345 | 추가: || crc32(0, &header[6..8]) != u32::from_le_bytes(header[8..].try_into().unwrap()) | |
| 346 | 추가: { | |
| 347 | 추가: return Err(ErrorCode::Integrity); | |
| 348 | 추가: } | |
| 349 | 추가: let check_size = match header[7] { | |
| 350 | 추가: 0 => 0, | |
| 351 | 추가: 1 => 4, | |
| 352 | 추가: 4 => 8, | |
| 353 | 추가: 10 => 32, | |
| 354 | 추가: _ => return Err(ErrorCode::UnsupportedFeature), | |
| 355 | 추가: }; | |
| 356 | 추가: let mut block_at = start + 12; | |
| 357 | 추가: for (unpadded, size) in records { | |
| 358 | 추가: xz_block(source, block_at, unpadded, size, check_size, check)?; | |
| 359 | 추가: block_at += (unpadded + 3) & !3; | |
| 360 | 추가: } | |
| 361 | 추가: end = start; | |
| 362 | 추가: } | |
| 363 | 추가: if streams == 0 { | |
| 364 | 추가: return Err(ErrorCode::Integrity); | |
| 365 | 추가: } | |
| 366 | 추가: Ok(total) | |
| 367 | 추가: } |
| @@ -10,6 +10,32 @@ use std::sync::atomic::{AtomicU64, Ordering}; | ||
| 10 | 10 | |
| 11 | 11 | type Result<T> = std::result::Result<T, ErrorCode>; |
| 12 | 12 | static TEMP: AtomicU64 = AtomicU64::new(0); |
| 13 | 추가: #[derive(Debug, PartialEq, Eq)] | |
| 14 | 추가: pub struct Existing { | |
| 15 | 추가: parent: SourceObject, | |
| 16 | 추가: object: SourceObject, | |
| 17 | 추가: pub size: u64, | |
| 18 | 추가: modified: std::time::SystemTime, | |
| 19 | 추가: } | |
| 20 | 추가: fn existing_file(parent: &File, file: File) -> Result<Existing> { | |
| 21 | 추가: let metadata = file.metadata().map_err(|_| ErrorCode::Io)?; | |
| 22 | 추가: if !metadata.is_file() { | |
| 23 | 추가: return Err(ErrorCode::UnsafePath); | |
| 24 | 추가: } | |
| 25 | 추가: #[cfg(windows)] | |
| 26 | 추가: { | |
| 27 | 추가: use std::os::windows::fs::MetadataExt; | |
| 28 | 추가: if metadata.file_attributes() & 0x400 != 0 { | |
| 29 | 추가: return Err(ErrorCode::UnsafePath); | |
| 30 | 추가: } | |
| 31 | 추가: } | |
| 32 | 추가: Ok(Existing { | |
| 33 | 추가: parent: object(parent)?, | |
| 34 | 추가: object: object(&file)?, | |
| 35 | 추가: size: metadata.len(), | |
| 36 | 추가: modified: metadata.modified().map_err(|_| ErrorCode::Io)?, | |
| 37 | 추가: }) | |
| 38 | 추가: } | |
| 13 | 39 | pub struct Snapshot { |
| 14 | 40 | pub bytes: Vec<u8>, |
| 15 | 41 | pub object: SourceObject, |
| @@ -163,6 +189,7 @@ mod platform { | ||
| 163 | 189 | fn openat(fd: i32, path: *const i8, flags: i32, ...) -> i32; |
| 164 | 190 | fn mkdirat(fd: i32, path: *const i8, mode: u32) -> i32; |
| 165 | 191 | fn linkat(fd: i32, path: *const i8, newfd: i32, newpath: *const i8, flags: i32) -> i32; |
| 192 | 추가: fn renameat(fd: i32, path: *const i8, newfd: i32, newpath: *const i8) -> i32; | |
| 166 | 193 | fn unlinkat(fd: i32, path: *const i8, flags: i32) -> i32; |
| 167 | 194 | fn geteuid() -> u32; |
| 168 | 195 | } |
| @@ -262,6 +289,31 @@ mod platform { | ||
| 262 | 289 | Err(_) => Err(ErrorCode::Io), |
| 263 | 290 | } |
| 264 | 291 | } |
| 292 | 추가: pub fn existing(&self, n: &str) -> Result<Option<Existing>> { | |
| 293 | 추가: match open(&self.file, std::ffi::OsStr::new(n), 0x200000) { | |
| 294 | 추가: Ok(file) => existing_file(&self.file, file).map(Some), | |
| 295 | 추가: Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(None), | |
| 296 | 추가: Err(_) => Err(ErrorCode::Io), | |
| 297 | 추가: } | |
| 298 | 추가: } | |
| 299 | 추가: pub fn replace(&self, from: &str, to: &str) -> std::io::Result<()> { | |
| 300 | 추가: let from = CString::new(from).unwrap(); | |
| 301 | 추가: let to = CString::new(to).unwrap(); | |
| 302 | 추가: // 고정 부모 안에서 완성된 임시 파일로 원본 이름을 교체함. | |
| 303 | 추가: if unsafe { | |
| 304 | 추가: renameat( | |
| 305 | 추가: self.file.as_raw_fd(), | |
| 306 | 추가: from.as_ptr(), | |
| 307 | 추가: self.file.as_raw_fd(), | |
| 308 | 추가: to.as_ptr(), | |
| 309 | 추가: ) | |
| 310 | 추가: } == 0 | |
| 311 | 추가: { | |
| 312 | 추가: Ok(()) | |
| 313 | 추가: } else { | |
| 314 | 추가: Err(std::io::Error::last_os_error()) | |
| 315 | 추가: } | |
| 316 | 추가: } | |
| 265 | 317 | pub fn create(&self, n: &str) -> std::io::Result<File> { |
| 266 | 318 | open(&self.file, std::ffi::OsStr::new(n), 1 | 0x40 | 0x80) |
| 267 | 319 | } |
| @@ -377,6 +429,45 @@ mod platform { | ||
| 377 | 429 | Err(_) => Err(ErrorCode::Io), |
| 378 | 430 | } |
| 379 | 431 | } |
| 432 | 추가: pub fn existing(&self, n: &str) -> Result<Option<Existing>> { | |
| 433 | 추가: match OpenOptions::new() | |
| 434 | 추가: .access_mode(0x80) | |
| 435 | 추가: .share_mode(7) | |
| 436 | 추가: .custom_flags(0x02000000 | 0x00200000) | |
| 437 | 추가: .open(self.path.join(n)) | |
| 438 | 추가: { | |
| 439 | 추가: Ok(file) => existing_file(self.handle(), file).map(Some), | |
| 440 | 추가: Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(None), | |
| 441 | 추가: Err(_) => Err(ErrorCode::Io), | |
| 442 | 추가: } | |
| 443 | 추가: } | |
| 444 | 추가: pub fn replace(&self, from: &str, to: &str) -> std::io::Result<()> { | |
| 445 | 추가: use std::os::windows::ffi::OsStrExt; | |
| 446 | 추가: unsafe extern "system" { | |
| 447 | 추가: fn MoveFileExW(from: *const u16, to: *const u16, flags: u32) -> i32; | |
| 448 | 추가: } | |
| 449 | 추가: let extended = |name: &str| { | |
| 450 | 추가: [92u16, 92, 63, 92] | |
| 451 | 추가: .into_iter() | |
| 452 | 추가: .chain( | |
| 453 | 추가: self.path | |
| 454 | 추가: .join(name) | |
| 455 | 추가: .as_os_str() | |
| 456 | 추가: .encode_wide() | |
| 457 | 추가: .map(|unit| if unit == 47 { 92 } else { unit }), | |
| 458 | 추가: ) | |
| 459 | 추가: .chain(Some(0)) | |
| 460 | 추가: .collect::<Vec<_>>() | |
| 461 | 추가: }; | |
| 462 | 추가: let from = extended(from); | |
| 463 | 추가: let to = extended(to); | |
| 464 | 추가: // 같은 부모의 이름만 교체하고 복사나 사전 삭제는 하지 않음. | |
| 465 | 추가: if unsafe { MoveFileExW(from.as_ptr(), to.as_ptr(), 1) } != 0 { | |
| 466 | 추가: Ok(()) | |
| 467 | 추가: } else { | |
| 468 | 추가: Err(std::io::Error::last_os_error()) | |
| 469 | 추가: } | |
| 470 | 추가: } | |
| 380 | 471 | pub fn create(&self, n: &str) -> std::io::Result<File> { |
| 381 | 472 | OpenOptions::new() |
| 382 | 473 | .write(true) |
| @@ -414,11 +505,30 @@ fn parent(root: &Dir, name: &str, create: bool) -> Result<Option<(Dir, String)>> | ||
| 414 | 505 | } |
| 415 | 506 | Ok(Some((d, leaf.to_owned()))) |
| 416 | 507 | } |
| 508 | 추가: pub fn existing(root: &Dir, name: &str) -> Result<Option<Existing>> { | |
| 509 | 추가: valid_name(name, false)?; | |
| 510 | 추가: match parent(root, name, false)? { | |
| 511 | 추가: Some((dir, leaf)) => dir.existing(&leaf), | |
| 512 | 추가: None => Ok(None), | |
| 513 | 추가: } | |
| 514 | 추가: } | |
| 515 | 추가: pub fn unused(root: &Dir, name: &str) -> Result<bool> { | |
| 516 | 추가: valid_name(name, false)?; | |
| 517 | 추가: match parent(root, name, false)? { | |
| 518 | 추가: Some((dir, leaf)) => dir.absent(&leaf), | |
| 519 | 추가: None => Ok(true), | |
| 520 | 추가: } | |
| 521 | 추가: } | |
| 417 | 522 | pub fn preflight(root: &Dir, names: &[(String, EntryKind)]) -> Result<()> { |
| 523 | 추가: preflight_mode(root, names, false) | |
| 524 | 추가: } | |
| 525 | 추가: pub fn preflight_mode(root: &Dir, names: &[(String, EntryKind)], interactive: bool) -> Result<()> { | |
| 418 | 526 | for (name, kind) in names { |
| 419 | 527 | if let Some((d, leaf)) = parent(root, name, false)? { |
| 420 | 528 | if *kind == EntryKind::Directory { |
| 421 | 529 | let _ = d.child(&leaf, false)?; |
| 530 | 추가: } else if interactive { | |
| 531 | 추가: d.existing(&leaf)?; | |
| 422 | 532 | } else if !d.absent(&leaf)? { |
| 423 | 533 | return Err(ErrorCode::Conflict); |
| 424 | 534 | } |
| @@ -507,6 +617,16 @@ pub fn publish_reader( | ||
| 507 | 617 | data: &mut impl Read, |
| 508 | 618 | length: u64, |
| 509 | 619 | check: &mut impl FnMut(bool) -> Result<()>, |
| 620 | 추가: ) -> Published { | |
| 621 | 추가: publish_reader_mode(root, name, data, length, None, check) | |
| 622 | 추가: } | |
| 623 | 추가: pub fn publish_reader_mode( | |
| 624 | 추가: root: &Dir, | |
| 625 | 추가: name: &str, | |
| 626 | 추가: data: &mut impl Read, | |
| 627 | 추가: length: u64, | |
| 628 | 추가: replace: Option<&Existing>, | |
| 629 | 추가: check: &mut impl FnMut(bool) -> Result<()>, | |
| 510 | 630 | ) -> Published { |
| 511 | 631 | let mut result = Published { |
| 512 | 632 | created: false, |
| @@ -550,10 +670,24 @@ pub fn publish_reader( | ||
| 550 | 670 | file.sync_all().map_err(crate::space::io_error) |
| 551 | 671 | })(); |
| 552 | 672 | let closed = close(file).map_err(crate::space::io_error); |
| 553 | 삭제: let mut finish = written.and(closed).and_then(|_| check(true)); | |
| 673 | 추가: let mut finish = written.and(closed).and_then(|_| { | |
| 674 | 추가: if let Some(expected) = replace { | |
| 675 | 추가: if dir.existing(&leaf)?.as_ref() != Some(expected) { | |
| 676 | 추가: return Err(ErrorCode::Conflict); | |
| 677 | 추가: } | |
| 678 | 추가: } | |
| 679 | 추가: check(true) | |
| 680 | 추가: }); | |
| 681 | 추가: let mut temp_consumed = false; | |
| 554 | 682 | if finish.is_ok() { |
| 555 | 삭제: match dir.link(&temp, &leaf) { | |
| 683 | 추가: let published = if replace.is_some() { | |
| 684 | 추가: dir.replace(&temp, &leaf) | |
| 685 | 추가: } else { | |
| 686 | 추가: dir.link(&temp, &leaf) | |
| 687 | 추가: }; | |
| 688 | 추가: match published { | |
| 556 | 689 | Ok(()) => { |
| 690 | 추가: temp_consumed = replace.is_some(); | |
| 557 | 691 | result.created = true; |
| 558 | 692 | match dir.sync_checked() { |
| 559 | 693 | Ok(durability) => result.durability = durability, |
| @@ -573,7 +707,7 @@ pub fn publish_reader( | ||
| 573 | 707 | } |
| 574 | 708 | } |
| 575 | 709 | } |
| 576 | 삭제: if !dir.remove(&temp) { | |
| 710 | 추가: if !temp_consumed && !dir.remove(&temp) { | |
| 577 | 711 | result.cleanup = Cleanup::Failed; |
| 578 | 712 | result.retained = 1; |
| 579 | 713 | result.retained_name = Some(match name.rsplit_once('/') { |
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | pub mod archive; |
| 2 | 추가: mod compressed_tar; | |
| 2 | 3 | mod create; |
| 3 | 4 | mod create_sources; |
| 4 | 5 | mod crypto; |
| @@ -255,6 +255,12 @@ pub enum PasswordPurpose { | ||
| 255 | 255 | Decrypt, |
| 256 | 256 | Encrypt, |
| 257 | 257 | } |
| 258 | 추가: #[derive(Clone, Copy, Debug, PartialEq, Eq)] | |
| 259 | 추가: pub enum ConflictChoice { | |
| 260 | 추가: Overwrite, | |
| 261 | 추가: Skip, | |
| 262 | 추가: Rename, | |
| 263 | 추가: } | |
| 258 | 264 | #[derive(Clone, Debug, PartialEq, Eq)] |
| 259 | 265 | pub struct Terminal { |
| 260 | 266 | pub outcome: Outcome, |
| @@ -285,6 +291,12 @@ pub enum Message { | ||
| 285 | 291 | secret: Secret, |
| 286 | 292 | }, |
| 287 | 293 | Cancel, |
| 294 | 추가: StartInteractive(Start), | |
| 295 | 추가: ConflictReply { | |
| 296 | 추가: challenge_id: u64, | |
| 297 | 추가: choice: ConflictChoice, | |
| 298 | 추가: apply_to_remaining: bool, | |
| 299 | 추가: }, | |
| 288 | 300 | Accepted { |
| 289 | 301 | action: ActionKind, |
| 290 | 302 | encryption: bool, |
| @@ -315,4 +327,16 @@ pub enum Message { | ||
| 315 | 327 | request_sequence: u64, |
| 316 | 328 | status: CancelStatus, |
| 317 | 329 | }, |
| 330 | 추가: ConflictRequired { | |
| 331 | 추가: challenge_id: u64, | |
| 332 | 추가: entry_id: u32, | |
| 333 | 추가: relative_name: String, | |
| 334 | 추가: incoming_size: u64, | |
| 335 | 추가: existing_size: u64, | |
| 336 | 추가: }, | |
| 337 | 추가: ConflictResolved { | |
| 338 | 추가: entry_id: u32, | |
| 339 | 추가: relative_name: String, | |
| 340 | 추가: choice: ConflictChoice, | |
| 341 | 추가: }, | |
| 318 | 342 | } |
| @@ -12,12 +12,18 @@ use std::{ | ||
| 12 | 12 | }; |
| 13 | 13 | |
| 14 | 14 | type Result<T> = std::result::Result<T, ErrorCode>; |
| 15 | 추가: #[derive(PartialEq, Eq)] | |
| 16 | 추가: enum Challenge { | |
| 17 | 추가: Password(u64), | |
| 18 | 추가: Conflict(u64), | |
| 19 | 추가: } | |
| 15 | 20 | struct State<W> { |
| 16 | 21 | writer: Writer<W>, |
| 17 | 22 | cancelled: bool, |
| 18 | 23 | phase: u8, |
| 19 | 24 | fault: Option<ErrorCode>, |
| 20 | 삭제: challenge: Option<u64>, | |
| 25 | 추가: challenge: Option<Challenge>, | |
| 26 | 추가: conflict_reply: Option<(ConflictChoice, bool)>, | |
| 21 | 27 | password: Option<Secret>, |
| 22 | 28 | input_closed: bool, |
| 23 | 29 | } |
| @@ -25,6 +31,8 @@ struct Job<W> { | ||
| 25 | 31 | state: Arc<Mutex<State<W>>>, |
| 26 | 32 | wake: Arc<Condvar>, |
| 27 | 33 | next_challenge: u64, |
| 34 | 추가: interactive: bool, | |
| 35 | 추가: remaining_choice: Option<ConflictChoice>, | |
| 28 | 36 | started: Instant, |
| 29 | 37 | terminal: Terminal, |
| 30 | 38 | parent: crate::parent::Parent, |
| @@ -36,7 +44,7 @@ impl<W: Write> Job<W> { | ||
| 36 | 44 | let id = self.next_challenge; |
| 37 | 45 | let state_ref = Arc::clone(&self.state); |
| 38 | 46 | let mut state = state_ref.lock().map_err(|_| ErrorCode::Internal)?; |
| 39 | 삭제: state.challenge = Some(id); | |
| 47 | 추가: state.challenge = Some(Challenge::Password(id)); | |
| 40 | 48 | state |
| 41 | 49 | .writer |
| 42 | 50 | .send(&Message::PasswordRequired { |
| @@ -70,6 +78,87 @@ impl<W: Write> Job<W> { | ||
| 70 | 78 | } |
| 71 | 79 | } |
| 72 | 80 | |
| 81 | 추가: fn conflict(&mut self, entry: &Entry, existing_size: u64) -> Result<ConflictChoice> { | |
| 82 | 추가: self.check()?; | |
| 83 | 추가: if let Some(choice) = self.remaining_choice { | |
| 84 | 추가: return Ok(choice); | |
| 85 | 추가: } | |
| 86 | 추가: self.next_challenge = self.next_challenge.checked_add(1).ok_or(ErrorCode::Limit)?; | |
| 87 | 추가: let id = self.next_challenge; | |
| 88 | 추가: let state_ref = Arc::clone(&self.state); | |
| 89 | 추가: let mut state = state_ref.lock().map_err(|_| ErrorCode::Internal)?; | |
| 90 | 추가: state.challenge = Some(Challenge::Conflict(id)); | |
| 91 | 추가: state | |
| 92 | 추가: .writer | |
| 93 | 추가: .send(&Message::ConflictRequired { | |
| 94 | 추가: challenge_id: id, | |
| 95 | 추가: entry_id: entry.entry_id, | |
| 96 | 추가: relative_name: entry.name.clone(), | |
| 97 | 추가: incoming_size: entry.size, | |
| 98 | 추가: existing_size, | |
| 99 | 추가: }) | |
| 100 | 추가: .map_err(|_| ErrorCode::Io)?; | |
| 101 | 추가: loop { | |
| 102 | 추가: self.parent.check()?; | |
| 103 | 추가: if let Some(error) = state.fault { | |
| 104 | 추가: return Err(error); | |
| 105 | 추가: } | |
| 106 | 추가: if state.cancelled { | |
| 107 | 추가: return Err(ErrorCode::None); | |
| 108 | 추가: } | |
| 109 | 추가: if let Some((choice, apply)) = state.conflict_reply.take() { | |
| 110 | 추가: if apply { | |
| 111 | 추가: self.remaining_choice = Some(choice); | |
| 112 | 추가: } | |
| 113 | 추가: return Ok(choice); | |
| 114 | 추가: } | |
| 115 | 추가: if state.input_closed { | |
| 116 | 추가: return Err(ErrorCode::Protocol); | |
| 117 | 추가: } | |
| 118 | 추가: if self.started.elapsed() > Duration::from_secs(300) { | |
| 119 | 추가: return Err(ErrorCode::Limit); | |
| 120 | 추가: } | |
| 121 | 추가: state = self | |
| 122 | 추가: .wake | |
| 123 | 추가: .wait_timeout(state, Duration::from_millis(50)) | |
| 124 | 추가: .map_err(|_| ErrorCode::Internal)? | |
| 125 | 추가: .0; | |
| 126 | 추가: } | |
| 127 | 추가: } | |
| 128 | 추가: fn rename(&mut self, root: &Dir, name: &str, reserved: &BTreeSet<String>) -> Result<String> { | |
| 129 | 추가: let (prefix, leaf) = name.rsplit_once('/').unwrap_or(("", name)); | |
| 130 | 추가: let (stem, extension) = match leaf.rsplit_once('.') { | |
| 131 | 추가: Some((stem, ext)) if !stem.is_empty() => (stem, format!(".{ext}")), | |
| 132 | 추가: _ => (leaf, String::new()), | |
| 133 | 추가: }; | |
| 134 | 추가: for index in 1..=10000 { | |
| 135 | 추가: self.check()?; | |
| 136 | 추가: fn clip(text: &str, bytes: usize) -> &str { | |
| 137 | 추가: let mut end = text.len().min(bytes); | |
| 138 | 추가: while !text.is_char_boundary(end) { | |
| 139 | 추가: end -= 1; | |
| 140 | 추가: } | |
| 141 | 추가: &text[..end] | |
| 142 | 추가: } | |
| 143 | 추가: let suffix = format!(" ({index})"); | |
| 144 | 추가: let extension = clip(&extension, 255 - suffix.len() - 4).trim_end_matches(['.', ' ']); | |
| 145 | 추가: let stem = clip(stem, 255 - suffix.len() - extension.len()); | |
| 146 | 추가: let stem = if stem.is_empty() { "file" } else { stem }; | |
| 147 | 추가: let leaf = format!("{stem}{suffix}{extension}"); | |
| 148 | 추가: let candidate = if prefix.is_empty() { | |
| 149 | 추가: leaf | |
| 150 | 추가: } else { | |
| 151 | 추가: format!("{prefix}/{leaf}") | |
| 152 | 추가: }; | |
| 153 | 추가: archive::valid_name(&candidate, false)?; | |
| 154 | 추가: if !reserved.contains(&candidate.to_lowercase()) | |
| 155 | 추가: && filesystem::unused(root, &candidate)? | |
| 156 | 추가: { | |
| 157 | 추가: return Ok(candidate); | |
| 158 | 추가: } | |
| 159 | 추가: } | |
| 160 | 추가: Err(ErrorCode::Conflict) | |
| 161 | 추가: } | |
| 73 | 162 | fn event(&mut self, event: Message) -> Result<()> { |
| 74 | 163 | let mut state = self.state.lock().map_err(|_| ErrorCode::Internal)?; |
| 75 | 164 | state.writer.send(&event).map_err(|_| { |
| @@ -122,6 +211,7 @@ impl<W: Write> Job<W> { | ||
| 122 | 211 | length: u64, |
| 123 | 212 | id: Option<u32>, |
| 124 | 213 | last: bool, |
| 214 | 추가: replace: Option<&filesystem::Existing>, | |
| 125 | 215 | ) -> Result<()> { |
| 126 | 216 | self.check()?; |
| 127 | 217 | self.progress( |
| @@ -130,7 +220,7 @@ impl<W: Write> Job<W> { | ||
| 130 | 220 | Some(length), |
| 131 | 221 | self.terminal.created_count as u32, |
| 132 | 222 | )?; |
| 133 | 삭제: let p = filesystem::publish_reader(root, name, data, length, &mut |commit| { | |
| 223 | 추가: let p = filesystem::publish_reader_mode(root, name, data, length, replace, &mut |commit| { | |
| 134 | 224 | if commit && last { |
| 135 | 225 | self.cutoff() |
| 136 | 226 | } else { |
| @@ -315,7 +405,13 @@ impl<W: Write> Job<W> { | ||
| 315 | 405 | } else { |
| 316 | 406 | None |
| 317 | 407 | }; |
| 318 | 삭제: 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)?; | |
| 319 | 415 | let encrypted = catalog.members.iter().any(|m| m.entry.encrypted); |
| 320 | 416 | if matches!(catalog.format, Format::Zip | Format::SevenZip) { |
| 321 | 417 | for attempt in 1..=3 { |
| @@ -366,8 +462,14 @@ impl<W: Write> Job<W> { | ||
| 366 | 462 | .iter() |
| 367 | 463 | .map(|m| (m.entry.name.clone(), EntryKind::File)), |
| 368 | 464 | ); |
| 369 | 삭제: filesystem::preflight(&root, &names)?; | |
| 370 | 삭제: filesystem::preflight_space(&root, &output_sizes, None)?; | |
| 465 | 추가: filesystem::preflight_mode(&root, &names, self.interactive)?; | |
| 466 | 추가: if !self.interactive { | |
| 467 | 추가: filesystem::preflight_space(&root, &output_sizes, None)?; | |
| 468 | 추가: } | |
| 469 | 추가: let mut reserved = names | |
| 470 | 추가: .iter() | |
| 471 | 추가: .map(|(name, _)| name.to_lowercase()) | |
| 472 | 추가: .collect::<BTreeSet<_>>(); | |
| 371 | 473 | for name in dirs { |
| 372 | 474 | self.check()?; |
| 373 | 475 | let (created, durability, sync_error) = |
| @@ -389,16 +491,53 @@ impl<W: Write> Job<W> { | ||
| 389 | 491 | for (index, m) in files.iter().enumerate() { |
| 390 | 492 | data.seek(SeekFrom::Start(offsets[m.entry.entry_id as usize])) |
| 391 | 493 | .map_err(|_| ErrorCode::Io)?; |
| 494 | 추가: self.check()?; | |
| 495 | 추가: let existing = if self.interactive { | |
| 496 | 추가: filesystem::existing(&root, &m.entry.name)? | |
| 497 | 추가: } else { | |
| 498 | 추가: None | |
| 499 | 추가: }; | |
| 500 | 추가: let mut name = m.entry.name.clone(); | |
| 501 | 추가: let mut replace = None; | |
| 502 | 추가: if let Some(ref existing) = existing { | |
| 503 | 추가: let choice = self.conflict(&m.entry, existing.size)?; | |
| 504 | 추가: self.check()?; | |
| 505 | 추가: if choice == ConflictChoice::Rename { | |
| 506 | 추가: name = self.rename(&root, &name, &reserved)?; | |
| 507 | 추가: reserved.insert(name.to_lowercase()); | |
| 508 | 추가: } else if choice == ConflictChoice::Overwrite { | |
| 509 | 추가: replace = Some(existing); | |
| 510 | 추가: } | |
| 511 | 추가: self.event(Message::ConflictResolved { | |
| 512 | 추가: entry_id: m.entry.entry_id, | |
| 513 | 추가: relative_name: name.clone(), | |
| 514 | 추가: choice, | |
| 515 | 추가: })?; | |
| 516 | 추가: if choice == ConflictChoice::Skip { | |
| 517 | 추가: continue; | |
| 518 | 추가: } | |
| 519 | 추가: } | |
| 520 | 추가: if self.interactive { | |
| 521 | 추가: // 건너뛴 파일을 제외하고 이번에 게시할 파일의 공간을 확인함. | |
| 522 | 추가: filesystem::preflight_space( | |
| 523 | 추가: &root, | |
| 524 | 추가: &[(name.clone(), m.entry.size)], | |
| 525 | 추가: None, | |
| 526 | 추가: )?; | |
| 527 | 추가: } | |
| 392 | 528 | self.output_reader( |
| 393 | 529 | &root, |
| 394 | 삭제: &m.entry.name, | |
| 530 | 추가: &name, | |
| 395 | 531 | &mut (&mut data).take(m.entry.size), |
| 396 | 532 | m.entry.size, |
| 397 | 533 | Some(m.entry.entry_id), |
| 398 | 534 | index + 1 == files.len(), |
| 535 | 추가: replace, | |
| 399 | 536 | )?; |
| 400 | 537 | } |
| 401 | 삭제: self.terminal.publication = Publication::Complete; | |
| 538 | 추가: if !self.interactive || self.terminal.created_count != 0 { | |
| 539 | 추가: self.terminal.publication = Publication::Complete; | |
| 540 | 추가: } | |
| 402 | 541 | } |
| 403 | 542 | } |
| 404 | 543 | Action::CreateZip { |
| @@ -433,7 +572,7 @@ impl<W: Write> Job<W> { | ||
| 433 | 572 | &mut || self.check(), |
| 434 | 573 | )?; |
| 435 | 574 | filesystem::preflight_space(&root, &[(name.clone(), length)], None)?; |
| 436 | 삭제: self.output_reader(&root, &name, &mut data, length, None, true)?; | |
| 575 | 추가: self.output_reader(&root, &name, &mut data, length, None, true, None)?; | |
| 437 | 576 | self.terminal.publication = Publication::Complete; |
| 438 | 577 | } |
| 439 | 578 | } |
| @@ -451,11 +590,15 @@ pub fn serve<R: Read + Send + 'static, W: Write + Send + 'static>( | ||
| 451 | 590 | let (job, _, message) = reader |
| 452 | 591 | .read()? |
| 453 | 592 | .ok_or_else(|| std::io::Error::from(std::io::ErrorKind::UnexpectedEof))?; |
| 454 | 삭제: let Message::Start(start) = message else { | |
| 455 | 삭제: return Err(std::io::Error::new( | |
| 456 | 삭제: std::io::ErrorKind::InvalidData, | |
| 457 | 삭제: "Start required", | |
| 458 | 삭제: )); | |
| 593 | 추가: let (start, interactive) = match message { | |
| 594 | 추가: Message::Start(start) => (start, false), | |
| 595 | 추가: Message::StartInteractive(start) => (start, true), | |
| 596 | 추가: _ => { | |
| 597 | 추가: return Err(std::io::Error::new( | |
| 598 | 추가: std::io::ErrorKind::InvalidData, | |
| 599 | 추가: "Start required", | |
| 600 | 추가: )); | |
| 601 | 추가: } | |
| 459 | 602 | }; |
| 460 | 603 | let state = Arc::new(Mutex::new(State { |
| 461 | 604 | writer: Writer::new(output, job), |
| @@ -463,6 +606,7 @@ pub fn serve<R: Read + Send + 'static, W: Write + Send + 'static>( | ||
| 463 | 606 | phase: 0, |
| 464 | 607 | fault: None, |
| 465 | 608 | challenge: None, |
| 609 | 추가: conflict_reply: None, | |
| 466 | 610 | password: None, |
| 467 | 611 | input_closed: false, |
| 468 | 612 | })); |
| @@ -494,7 +638,7 @@ pub fn serve<R: Read + Send + 'static, W: Write + Send + 'static>( | ||
| 494 | 638 | secret, |
| 495 | 639 | } => { |
| 496 | 640 | if state.phase != 0 |
| 497 | 삭제: || state.challenge != Some(challenge_id) | |
| 641 | 추가: || state.challenge != Some(Challenge::Password(challenge_id)) | |
| 498 | 642 | || state.password.is_some() |
| 499 | 643 | { |
| 500 | 644 | state.fault = Some(ErrorCode::Protocol); |
| @@ -506,6 +650,24 @@ pub fn serve<R: Read + Send + 'static, W: Write + Send + 'static>( | ||
| 506 | 650 | } |
| 507 | 651 | control_wake.notify_all(); |
| 508 | 652 | } |
| 653 | 추가: Message::ConflictReply { | |
| 654 | 추가: challenge_id, | |
| 655 | 추가: choice, | |
| 656 | 추가: apply_to_remaining, | |
| 657 | 추가: } => { | |
| 658 | 추가: if state.phase != 0 | |
| 659 | 추가: || state.challenge != Some(Challenge::Conflict(challenge_id)) | |
| 660 | 추가: || state.conflict_reply.is_some() | |
| 661 | 추가: { | |
| 662 | 추가: state.fault = Some(ErrorCode::Protocol); | |
| 663 | 추가: } else { | |
| 664 | 추가: state.challenge = None; | |
| 665 | 추가: if !state.cancelled { | |
| 666 | 추가: state.conflict_reply = Some((choice, apply_to_remaining)); | |
| 667 | 추가: } | |
| 668 | 추가: } | |
| 669 | 추가: control_wake.notify_all(); | |
| 670 | 추가: } | |
| 509 | 671 | Message::Cancel => { |
| 510 | 672 | let status = match state.phase { |
| 511 | 673 | 2 => CancelStatus::Finished, |
| @@ -540,6 +702,8 @@ pub fn serve<R: Read + Send + 'static, W: Write + Send + 'static>( | ||
| 540 | 702 | state: Arc::clone(&state), |
| 541 | 703 | wake, |
| 542 | 704 | next_challenge: 0, |
| 705 | 추가: interactive, | |
| 706 | 추가: remaining_choice: None, | |
| 543 | 707 | parent, |
| 544 | 708 | started: Instant::now(), |
| 545 | 709 | terminal: Terminal { |
| @@ -568,6 +732,7 @@ pub fn serve<R: Read + Send + 'static, W: Write + Send + 'static>( | ||
| 568 | 732 | state.phase = 2; |
| 569 | 733 | state.challenge = None; |
| 570 | 734 | state.password = None; |
| 735 | 추가: state.conflict_reply = None; | |
| 571 | 736 | if let Some(error) = state.fault.or(error) { |
| 572 | 737 | context.terminal.error = error; |
| 573 | 738 | context.terminal.outcome = if error == ErrorCode::None { |
| @@ -66,6 +66,21 @@ impl Catalog { | ||
| 66 | 66 | { |
| 67 | 67 | return zip(source, len, limits, decode, password, check); |
| 68 | 68 | } |
| 69 | 추가: let compression = if magic.starts_with(b"BZh") { | |
| 70 | 추가: Some(crate::compressed_tar::Compression::Bzip2) | |
| 71 | 추가: } else if &magic == b"\xfd7zXZ\0" { | |
| 72 | 추가: Some(crate::compressed_tar::Compression::Xz) | |
| 73 | 추가: } else { | |
| 74 | 추가: None | |
| 75 | 추가: }; | |
| 76 | 추가: if let Some(compression) = compression { | |
| 77 | 추가: let (data, expanded) = | |
| 78 | 추가: crate::compressed_tar::decode(source, compression, limits.output, check)?; | |
| 79 | 추가: if expanded < 1024 { | |
| 80 | 추가: return Err(ErrorCode::Integrity); | |
| 81 | 추가: } | |
| 82 | 추가: return tar(data, expanded, limits, Format::Tar, check); | |
| 83 | 추가: } | |
| 69 | 84 | if magic.starts_with(&[31, 139]) { |
| 70 | 85 | let mut data = spool::temporary()?; |
| 71 | 86 | io(source.rewind())?; |
| @@ -139,6 +139,7 @@ enumeration!(Durability{NotApplicable=0,Synced=1,Unconfirmed=2,Failed=3}); | ||
| 139 | 139 | enumeration!(Cleanup{Complete=0,Failed=1,Unconfirmed=2}); |
| 140 | 140 | enumeration!(CancelStatus{Requested=0,AlreadyRequested=1,TooLate=2,Finished=3}); |
| 141 | 141 | enumeration!(PasswordPurpose{Decrypt=0,Encrypt=1}); |
| 142 | 추가: enumeration!(ConflictChoice{Overwrite=0,Skip=1,Rename=2}); | |
| 142 | 143 | macro_rules! structure {($t:ident {$($f:ident),*})=>{impl Wire for $t { |
| 143 | 144 | fn enc(&self,e:&mut Encoder)->io::Result<()> {$(self.$f.enc(e)?;)*Ok(())} |
| 144 | 145 | fn dec(d:&mut Decoder<'_>)->io::Result<Self> {Ok(Self {$($f:Wire::dec(d)?,)*})} |
| @@ -323,6 +324,23 @@ impl Message { | ||
| 323 | 324 | 2 |
| 324 | 325 | } |
| 325 | 326 | Self::Cancel => 3, |
| 327 | 추가: Self::StartInteractive(v) => { | |
| 328 | 추가: if !matches!(&v.action, Action::Extract { .. }) { | |
| 329 | 추가: return Err(invalid()); | |
| 330 | 추가: } | |
| 331 | 추가: v.enc(&mut e)?; | |
| 332 | 추가: 4 | |
| 333 | 추가: } | |
| 334 | 추가: Self::ConflictReply { | |
| 335 | 추가: challenge_id, | |
| 336 | 추가: choice, | |
| 337 | 추가: apply_to_remaining, | |
| 338 | 추가: } => { | |
| 339 | 추가: challenge_id.enc(&mut e)?; | |
| 340 | 추가: choice.enc(&mut e)?; | |
| 341 | 추가: apply_to_remaining.enc(&mut e)?; | |
| 342 | 추가: 5 | |
| 343 | 추가: } | |
| 326 | 344 | Self::Accepted { action, encryption } => { |
| 327 | 345 | action.enc(&mut e)?; |
| 328 | 346 | encryption.enc(&mut e)?; |
| @@ -387,6 +405,30 @@ impl Message { | ||
| 387 | 405 | status.enc(&mut e)?; |
| 388 | 406 | 107 |
| 389 | 407 | } |
| 408 | 추가: Self::ConflictRequired { | |
| 409 | 추가: challenge_id, | |
| 410 | 추가: entry_id, | |
| 411 | 추가: relative_name, | |
| 412 | 추가: incoming_size, | |
| 413 | 추가: existing_size, | |
| 414 | 추가: } => { | |
| 415 | 추가: challenge_id.enc(&mut e)?; | |
| 416 | 추가: entry_id.enc(&mut e)?; | |
| 417 | 추가: relative_name.enc(&mut e)?; | |
| 418 | 추가: incoming_size.enc(&mut e)?; | |
| 419 | 추가: existing_size.enc(&mut e)?; | |
| 420 | 추가: 108 | |
| 421 | 추가: } | |
| 422 | 추가: Self::ConflictResolved { | |
| 423 | 추가: entry_id, | |
| 424 | 추가: relative_name, | |
| 425 | 추가: choice, | |
| 426 | 추가: } => { | |
| 427 | 추가: entry_id.enc(&mut e)?; | |
| 428 | 추가: relative_name.enc(&mut e)?; | |
| 429 | 추가: choice.enc(&mut e)?; | |
| 430 | 추가: 109 | |
| 431 | 추가: } | |
| 390 | 432 | }; |
| 391 | 433 | Ok((kind, e.bytes)) |
| 392 | 434 | } |
| @@ -406,6 +448,18 @@ impl Message { | ||
| 406 | 448 | } |
| 407 | 449 | } |
| 408 | 450 | 3 => Self::Cancel, |
| 451 | 추가: 4 => { | |
| 452 | 추가: let start = Start::dec(&mut d)?; | |
| 453 | 추가: if !matches!(&start.action, Action::Extract { .. }) { | |
| 454 | 추가: return Err(invalid()); | |
| 455 | 추가: } | |
| 456 | 추가: Self::StartInteractive(start) | |
| 457 | 추가: } | |
| 458 | 추가: 5 => Self::ConflictReply { | |
| 459 | 추가: challenge_id: Wire::dec(&mut d)?, | |
| 460 | 추가: choice: Wire::dec(&mut d)?, | |
| 461 | 추가: apply_to_remaining: Wire::dec(&mut d)?, | |
| 462 | 추가: }, | |
| 409 | 463 | 100 => Self::Accepted { |
| 410 | 464 | action: Wire::dec(&mut d)?, |
| 411 | 465 | encryption: Wire::dec(&mut d)?, |
| @@ -442,6 +496,18 @@ impl Message { | ||
| 442 | 496 | request_sequence: Wire::dec(&mut d)?, |
| 443 | 497 | status: Wire::dec(&mut d)?, |
| 444 | 498 | }, |
| 499 | 추가: 108 => Self::ConflictRequired { | |
| 500 | 추가: challenge_id: Wire::dec(&mut d)?, | |
| 501 | 추가: entry_id: Wire::dec(&mut d)?, | |
| 502 | 추가: relative_name: Wire::dec(&mut d)?, | |
| 503 | 추가: incoming_size: Wire::dec(&mut d)?, | |
| 504 | 추가: existing_size: Wire::dec(&mut d)?, | |
| 505 | 추가: }, | |
| 506 | 추가: 109 => Self::ConflictResolved { | |
| 507 | 추가: entry_id: Wire::dec(&mut d)?, | |
| 508 | 추가: relative_name: Wire::dec(&mut d)?, | |
| 509 | 추가: choice: Wire::dec(&mut d)?, | |
| 510 | 추가: }, | |
| 445 | 511 | _ => return Err(invalid()), |
| 446 | 512 | }; |
| 447 | 513 | if d.at != b.len() { |
| @@ -124,7 +124,7 @@ checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" | ||
| 124 | 124 | dependencies = [ |
| 125 | 125 | "cfg-if", |
| 126 | 126 | "cipher", |
| 127 | 삭제: "cpufeatures", | |
| 127 | 추가: "cpufeatures 0.2.17", | |
| 128 | 128 | "zeroize", |
| 129 | 129 | ] |
| 130 | 130 | |
| @@ -462,6 +462,15 @@ dependencies = [ | ||
| 462 | 462 | "generic-array", |
| 463 | 463 | ] |
| 464 | 464 | |
| 465 | 추가: [[package]] | |
| 466 | 추가: name = "block-buffer" | |
| 467 | 추가: version = "0.12.1" | |
| 468 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 469 | 추가: checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" | |
| 470 | 추가: dependencies = [ | |
| 471 | 추가: "hybrid-array", | |
| 472 | 추가: ] | |
| 473 | 추가: | |
| 465 | 474 | [[package]] |
| 466 | 475 | name = "block2" |
| 467 | 476 | version = "0.5.1" |
| @@ -531,6 +540,15 @@ version = "1.12.1" | ||
| 531 | 540 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 532 | 541 | checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" |
| 533 | 542 | |
| 543 | 추가: [[package]] | |
| 544 | 추가: name = "bzip2" | |
| 545 | 추가: version = "0.6.1" | |
| 546 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 547 | 추가: checksum = "f3a53fac24f34a81bc9954b5d6cfce0c21e18ec6959f44f56e8e90e4bb7c346c" | |
| 548 | 추가: dependencies = [ | |
| 549 | 추가: "libbz2-rs-sys", | |
| 550 | 추가: ] | |
| 551 | 추가: | |
| 534 | 552 | [[package]] |
| 535 | 553 | name = "calloop" |
| 536 | 554 | version = "0.13.0" |
| @@ -620,7 +638,7 @@ version = "0.4.4" | ||
| 620 | 638 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 621 | 639 | checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" |
| 622 | 640 | dependencies = [ |
| 623 | 삭제: "crypto-common", | |
| 641 | 추가: "crypto-common 0.1.7", | |
| 624 | 642 | "inout", |
| 625 | 643 | ] |
| 626 | 644 | |
| @@ -670,6 +688,12 @@ dependencies = [ | ||
| 670 | 688 | "crossbeam-utils", |
| 671 | 689 | ] |
| 672 | 690 | |
| 691 | 추가: [[package]] | |
| 692 | 추가: name = "const-oid" | |
| 693 | 추가: version = "0.10.3" | |
| 694 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 695 | 추가: checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" | |
| 696 | 추가: | |
| 673 | 697 | [[package]] |
| 674 | 698 | name = "constant_time_eq" |
| 675 | 699 | version = "0.6.1" |
| @@ -728,6 +752,15 @@ dependencies = [ | ||
| 728 | 752 | "libc", |
| 729 | 753 | ] |
| 730 | 754 | |
| 755 | 추가: [[package]] | |
| 756 | 추가: name = "cpufeatures" | |
| 757 | 추가: version = "0.3.1" | |
| 758 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 759 | 추가: checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" | |
| 760 | 추가: dependencies = [ | |
| 761 | 추가: "libc", | |
| 762 | 추가: ] | |
| 763 | 추가: | |
| 731 | 764 | [[package]] |
| 732 | 765 | name = "crc32fast" |
| 733 | 766 | version = "1.5.5" |
| @@ -759,6 +792,15 @@ dependencies = [ | ||
| 759 | 792 | "typenum", |
| 760 | 793 | ] |
| 761 | 794 | |
| 795 | 추가: [[package]] | |
| 796 | 추가: name = "crypto-common" | |
| 797 | 추가: version = "0.2.2" | |
| 798 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 799 | 추가: checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" | |
| 800 | 추가: dependencies = [ | |
| 801 | 추가: "hybrid-array", | |
| 802 | 추가: ] | |
| 803 | 추가: | |
| 762 | 804 | [[package]] |
| 763 | 805 | name = "cursor-icon" |
| 764 | 806 | version = "1.2.0" |
| @@ -771,11 +813,22 @@ version = "0.10.7" | ||
| 771 | 813 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 772 | 814 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" |
| 773 | 815 | dependencies = [ |
| 774 | 삭제: "block-buffer", | |
| 775 | 삭제: "crypto-common", | |
| 816 | 추가: "block-buffer 0.10.4", | |
| 817 | 추가: "crypto-common 0.1.7", | |
| 776 | 818 | "subtle", |
| 777 | 819 | ] |
| 778 | 820 | |
| 821 | 추가: [[package]] | |
| 822 | 추가: name = "digest" | |
| 823 | 추가: version = "0.11.3" | |
| 824 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 825 | 추가: checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" | |
| 826 | 추가: dependencies = [ | |
| 827 | 추가: "block-buffer 0.12.1", | |
| 828 | 추가: "const-oid", | |
| 829 | 추가: "crypto-common 0.2.2", | |
| 830 | 추가: ] | |
| 831 | 추가: | |
| 779 | 832 | [[package]] |
| 780 | 833 | name = "dispatch" |
| 781 | 834 | version = "0.2.0" |
| @@ -1533,7 +1586,16 @@ version = "0.12.1" | ||
| 1533 | 1586 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1534 | 1587 | checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" |
| 1535 | 1588 | dependencies = [ |
| 1536 | 삭제: "digest", | |
| 1589 | 추가: "digest 0.10.7", | |
| 1590 | 추가: ] | |
| 1591 | 추가: | |
| 1592 | 추가: [[package]] | |
| 1593 | 추가: name = "hybrid-array" | |
| 1594 | 추가: version = "0.4.15" | |
| 1595 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1596 | 추가: checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" | |
| 1597 | 추가: dependencies = [ | |
| 1598 | 추가: "typenum", | |
| 1537 | 1599 | ] |
| 1538 | 1600 | |
| 1539 | 1601 | [[package]] |
| @@ -1779,6 +1841,12 @@ dependencies = [ | ||
| 1779 | 1841 | "smallvec", |
| 1780 | 1842 | ] |
| 1781 | 1843 | |
| 1844 | 추가: [[package]] | |
| 1845 | 추가: name = "libbz2-rs-sys" | |
| 1846 | 추가: version = "0.2.6" | |
| 1847 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1848 | 추가: checksum = "32f454fd6831a29c0e827ed075bca2a15be201bd57f4168f0fd1041124eab17e" | |
| 1849 | 추가: | |
| 1782 | 1850 | [[package]] |
| 1783 | 1851 | name = "libc" |
| 1784 | 1852 | version = "0.2.191" |
| @@ -1858,6 +1926,15 @@ version = "0.4.35" | ||
| 1858 | 1926 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1859 | 1927 | checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" |
| 1860 | 1928 | |
| 1929 | 추가: [[package]] | |
| 1930 | 추가: name = "lzma-rust2" | |
| 1931 | 추가: version = "0.25.0" | |
| 1932 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1933 | 추가: checksum = "ef1d73c59a56771343712b22ea5615092c612c16ba291c0979e3105dfeec4890" | |
| 1934 | 추가: dependencies = [ | |
| 1935 | 추가: "sha2 0.11.1", | |
| 1936 | 추가: ] | |
| 1937 | 추가: | |
| 1861 | 1938 | [[package]] |
| 1862 | 1939 | name = "memchr" |
| 1863 | 1940 | version = "2.8.3" |
| @@ -2419,7 +2496,7 @@ version = "0.12.2" | ||
| 2419 | 2496 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2420 | 2497 | checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" |
| 2421 | 2498 | dependencies = [ |
| 2422 | 삭제: "digest", | |
| 2499 | 추가: "digest 0.10.7", | |
| 2423 | 2500 | "hmac", |
| 2424 | 2501 | ] |
| 2425 | 2502 | |
| @@ -2966,8 +3043,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 2966 | 3043 | checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" |
| 2967 | 3044 | dependencies = [ |
| 2968 | 3045 | "cfg-if", |
| 2969 | 삭제: "cpufeatures", | |
| 2970 | 삭제: "digest", | |
| 3046 | 추가: "cpufeatures 0.2.17", | |
| 3047 | 추가: "digest 0.10.7", | |
| 2971 | 3048 | ] |
| 2972 | 3049 | |
| 2973 | 3050 | [[package]] |
| @@ -2977,8 +3054,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 2977 | 3054 | checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" |
| 2978 | 3055 | dependencies = [ |
| 2979 | 3056 | "cfg-if", |
| 2980 | 삭제: "cpufeatures", | |
| 2981 | 삭제: "digest", | |
| 3057 | 추가: "cpufeatures 0.2.17", | |
| 3058 | 추가: "digest 0.10.7", | |
| 3059 | 추가: ] | |
| 3060 | 추가: | |
| 3061 | 추가: [[package]] | |
| 3062 | 추가: name = "sha2" | |
| 3063 | 추가: version = "0.11.1" | |
| 3064 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3065 | 추가: checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" | |
| 3066 | 추가: dependencies = [ | |
| 3067 | 추가: "cfg-if", | |
| 3068 | 추가: "cpufeatures 0.3.1", | |
| 3069 | 추가: "digest 0.11.3", | |
| 2982 | 3070 | ] |
| 2983 | 3071 | |
| 2984 | 3072 | [[package]] |
| @@ -4564,10 +4652,12 @@ name = "zipelo-archive-worker" | ||
| 4564 | 4652 | version = "0.1.0" |
| 4565 | 4653 | dependencies = [ |
| 4566 | 4654 | "aes", |
| 4655 | 추가: "bzip2", | |
| 4567 | 4656 | "hmac", |
| 4657 | 추가: "lzma-rust2", | |
| 4568 | 4658 | "pbkdf2", |
| 4569 | 4659 | "sha1", |
| 4570 | 삭제: "sha2", | |
| 4660 | 추가: "sha2 0.10.9", | |
| 4571 | 4661 | "subtle", |
| 4572 | 4662 | "zeroize", |
| 4573 | 4663 | "zlib-rs", |
| @@ -4584,7 +4674,7 @@ dependencies = [ | ||
| 4584 | 4674 | name = "zipelo-memory-ustar-reader" |
| 4585 | 4675 | version = "0.1.0" |
| 4586 | 4676 | dependencies = [ |
| 4587 | 삭제: "sha2", | |
| 4677 | 추가: "sha2 0.10.9", | |
| 4588 | 4678 | "subtle", |
| 4589 | 4679 | ] |
| 4590 | 4680 |
| @@ -37,7 +37,7 @@ pub trait Dialogs { | ||
| 37 | 37 | |
| 38 | 38 | pub fn archive_filters() -> Vec<(&'static str, Vec<String>)> { |
| 39 | 39 | let mut extensions = Vec::new(); |
| 40 | 삭제: for extension in ["zip", "7z", "tar", "gz", "tgz"] { | |
| 40 | 추가: for extension in ["zip", "7z", "tar", "gz", "tgz", "tar.bz2", "tar.xz"] { | |
| 41 | 41 | let mut variants = vec![String::new()]; |
| 42 | 42 | for character in extension.chars() { |
| 43 | 43 | let mut next = Vec::new(); |
| @@ -70,8 +70,11 @@ pub fn middle_text(text: &str, max_chars: usize) -> String { | ||
| 70 | 70 | pub fn default_destination(archive: &Path) -> PathBuf { |
| 71 | 71 | let name = archive.file_name().unwrap_or_default().to_string_lossy(); |
| 72 | 72 | let lower = name.to_ascii_lowercase(); |
| 73 | 삭제: let stem = if lower.ends_with(".tar.gz") { | |
| 74 | 삭제: &name[..name.len() - 7] | |
| 73 | 추가: let compound = [".tar.bz2", ".tar.gz", ".tar.xz"] | |
| 74 | 추가: .into_iter() | |
| 75 | 추가: .find(|suffix| lower.ends_with(suffix)); | |
| 76 | 추가: let stem = if let Some(suffix) = compound { | |
| 77 | 추가: &name[..name.len() - suffix.len()] | |
| 75 | 78 | } else { |
| 76 | 79 | name.rsplit_once('.') |
| 77 | 80 | .map_or(name.as_ref(), |(stem, _)| stem) |
| @@ -1103,7 +1103,7 @@ impl ArchiveApp { | ||
| 1103 | 1103 | ui.add_space(theme::PAD as f32); |
| 1104 | 1104 | ui.colored_label( |
| 1105 | 1105 | theme::MUTED, |
| 1106 | 삭제: "ZIP, 7z, TAR, GZ, TAR.GZ 파일을 열 수 있습니다", | |
| 1106 | 추가: "ZIP, 7z, TAR, GZ, TAR.GZ, TAR.BZ2, TAR.XZ 파일을 열 수 있습니다", | |
| 1107 | 1107 | ); |
| 1108 | 1108 | }); |
| 1109 | 1109 | } |
| @@ -58,7 +58,7 @@ Architecture: amd64 | ||
| 58 | 58 | Maintainer: Zipelo contributors <[email protected]> |
| 59 | 59 | Section: utils |
| 60 | 60 | Priority: optional |
| 61 | 삭제: Depends: libc6 (>= 2.39), libgcc-s1, libx11-6, libxkbcommon0, libwayland-client0, libegl1, libgl1, libfontconfig1, fonts-noto-cjk, xdg-utils, desktop-file-utils | |
| 61 | 추가: Depends: libc6 (>= 2.39), libgcc-s1, libx11-6, libxkbcommon0, libxkbcommon-x11-0, libwayland-client0, libegl1, libgl1, libfontconfig1, fonts-noto-cjk, xdg-utils, desktop-file-utils | |
| 62 | 62 | Description: Lightweight Rust archive application |
| 63 | 63 | ZIP, 7z, TAR, GZ and TAR.GZ archive application with a separate worker. |
| 64 | 64 | """) |
| @@ -16,8 +16,8 @@ python3 tests/ci/run_rust.py local | ||
| 16 | 16 | - `setup_windows.sh`는 관리자 권한 없이 도구를 `tests/ci/tools`에 풉니다. apt-get, dpkg-deb, rustup 및 GCC 호스트 실행 라이브러리가 필요합니다. 공용 도구 경로를 재사용할 때는 프로젝트 안의 소유 경로를 `ZIPELO_CI_TOOLS`로 지정합니다. 연결된 Git worktree에서는 현재 checkout의 도구를 먼저 찾고 같은 저장소 기본 worktree의 `tests/ci/tools`도 찾습니다. `ZIPELO_CI_TOOLS`를 지정하면 그 경로만 사용하며 별도 PATH 내보내기는 필요하지 않습니다. 기존 Rust target과 MinGW가 있으면 준비 스크립트 없이 PATH와 관련 Cargo/CC/CXX 환경 설정을 사용할 수 있습니다. |
| 17 | 17 | - Linux GUI 빌드에는 pkg-config, libxkbcommon-dev, libwayland-dev, libgl1-mesa-dev가 필요하며 글꼴 시험에는 fonts-noto-cjk가 필요합니다. |
| 18 | 18 | - 추적된 fixture를 Git blob과 대조합니다. Windows checkout 시 core.autocrlf=false를 사용해야 하며 기대값의 바이트를 바꾸지 않습니다. |
| 19 | 삭제: - Unix 소켓 시험을 위해 짧은 checkout 경로를 사용합니다. 예: 프로젝트 아래 `tests/ci-k`. 기존 `runs` 디렉터리는 소유권, 0700, 빈 상태를 확인하고 새 디렉터리만 생성합니다. 실패한 fixture는 삭제하거나 권한을 바꾸지 않습니다. | |
| 20 | 삭제: - 파일 게시 계층은 ext4/XFS만 지원합니다. tmpfs 등 다른 파일시스템에서는 `rust-file-publication`과 `rust-gzip-file-job`의 Rust 실행 시험만 `not-applicable`로 기록하고 파일시스템 식별값과 사유를 출력합니다. 해당 crate의 Linux 및 Windows 빌드와 snapshot 등 나머지 시험은 계속합니다. 전체 시험 통과가 필요한 검증은 짧은 ext4/XFS checkout에서 수행합니다. 파일시스템 탐색 오류나 기존 시험 디렉터리의 소유권 문제는 실패로 남깁니다. | |
| 19 | 추가: - Unix 소켓 시험은 Cargo가 설정한 시험 crate의 현재 디렉터리에서 짧은 상대 경로로 소켓을 생성합니다. 소켓 파일은 기존 `runs` 안에 유지하며 긴 checkout 절대 경로에서도 실행됩니다. 별도 경로 매핑이나 `/tmp` 사용은 필요하지 않습니다. 기존 `runs` 디렉터리는 소유권, 0700, 빈 상태를 확인하고 새 디렉터리만 생성합니다. 실패한 fixture는 삭제하거나 권한을 바꾸지 않습니다. | |
| 20 | 추가: - 파일 게시 계층은 ext4/XFS만 지원합니다. tmpfs 등 다른 파일시스템에서는 `rust-file-publication`과 `rust-gzip-file-job`의 Rust 실행 시험만 `not-applicable`로 기록하고 파일시스템 식별값과 사유를 출력합니다. 해당 crate의 Linux 및 Windows 빌드와 snapshot 등 나머지 시험은 계속합니다. 전체 시험 통과가 필요한 검증은 ext4/XFS checkout에서 수행합니다. 파일시스템 탐색 오류나 기존 시험 디렉터리의 소유권 문제는 실패로 남깁니다. | |
| 21 | 21 | - 개별 단계는 `build`, `test`, `cross-build`로 실행할 수 있습니다. 한 crate가 실패해도 다른 crate 결과를 수집합니다. |
| 22 | 22 | - GUI 앱과 GUI race harness는 컴파일하며 실제 화면 시나리오는 실행하지 않습니다. C# 시험과 역사적 hash 검사는 포함하지 않습니다. |
| 23 | 23 |
| @@ -75,10 +75,6 @@ def prepare_fixtures(root): | ||
| 75 | 75 | " (tmpfs 포함 다른 파일시스템은 제품 코드에서 지원하지 않음)" |
| 76 | 76 | ) |
| 77 | 77 | continue |
| 78 | 삭제: if name == "rust-file-publication": | |
| 79 | 삭제: socket = path / "case-2147483647-99/parent/output" | |
| 80 | 삭제: if len(os.fsencode(socket)) >= 108: | |
| 81 | 삭제: raise ValueError("Unix 소켓 시험을 위해 더 짧은 checkout 경로가 필요함") | |
| 82 | 78 | return skipped |
| 83 | 79 | |
| 84 | 80 |
| @@ -210,6 +210,21 @@ class RunnerTests(unittest.TestCase): | ||
| 210 | 210 | self.assertTrue(all(row["status"] == "passed" for row in results)) |
| 211 | 211 | self.assertEqual(cargo.call_count, 4) |
| 212 | 212 | |
| 213 | 추가: @unittest.skipUnless(sys.platform == "linux", "Linux 소켓 경로 회귀 시험임") | |
| 214 | 추가: def test_long_checkout_does_not_block_file_fixtures(self): | |
| 215 | 추가: work = run_rust.ROOT / "tests/work" | |
| 216 | 추가: work.mkdir(exist_ok=True) | |
| 217 | 추가: with tempfile.TemporaryDirectory(dir=work) as directory: | |
| 218 | 추가: root = Path(directory) / ("long-checkout-" * 10) | |
| 219 | 추가: for name in run_rust.FILE_FIXTURES: | |
| 220 | 추가: (root / "tests" / name).mkdir(parents=True) | |
| 221 | 추가: socket = root / "tests/rust-file-publication/runs/case-1-1/parent/output" | |
| 222 | 추가: self.assertGreaterEqual(len(run_rust.os.fsencode(socket)), 108) | |
| 223 | 추가: with patch.object(run_rust.subprocess, "check_output", return_value="ef53\n"): | |
| 224 | 추가: self.assertEqual(run_rust.prepare_fixtures(root), {}) | |
| 225 | 추가: for name in run_rust.FILE_FIXTURES: | |
| 226 | 추가: self.assertEqual(list((root / "tests" / name / "runs").iterdir()), []) | |
| 227 | 추가: | |
| 213 | 228 | def test_unknown_filesystem_probe_error_is_failure(self): |
| 214 | 229 | with ( |
| 215 | 230 | patch.object(run_rust, "prepare_fixtures", side_effect=subprocess.CalledProcessError(1, "stat")), |
| @@ -0,0 +1,39 @@ | ||
| 1 | 추가: """압축 TAR 의존성의 원문 고지와 Rust 백엔드를 검증함.""" | |
| 2 | 추가: | |
| 3 | 추가: import importlib.util | |
| 4 | 추가: from pathlib import Path | |
| 5 | 추가: import unittest | |
| 6 | 추가: | |
| 7 | 추가: | |
| 8 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 9 | 추가: SPEC = importlib.util.spec_from_file_location("compressed_tar_licenses", ROOT / "packaging/licenses.py") | |
| 10 | 추가: LICENSES = importlib.util.module_from_spec(SPEC) | |
| 11 | 추가: SPEC.loader.exec_module(LICENSES) | |
| 12 | 추가: | |
| 13 | 추가: | |
| 14 | 추가: class CompressedTarLicenses(unittest.TestCase): | |
| 15 | 추가: def test_registry_originals_are_in_generated_worker_notice(self): | |
| 16 | 추가: manifest = ROOT / "experiments/rust-archive-worker/Cargo.toml" | |
| 17 | 추가: records = LICENSES.inventory([manifest]) | |
| 18 | 추가: selected = {record["name"]: record for record in records} | |
| 19 | 추가: expected = { | |
| 20 | 추가: "bzip2": ("0.6.1", "MIT OR Apache-2.0"), | |
| 21 | 추가: "libbz2-rs-sys": ("0.2.6", "bzip2-1.0.6"), | |
| 22 | 추가: "lzma-rust2": ("0.25.0", "Apache-2.0"), | |
| 23 | 추가: } | |
| 24 | 추가: notice = LICENSES.render(records) | |
| 25 | 추가: for name, (version, license_id) in expected.items(): | |
| 26 | 추가: with self.subTest(name=name): | |
| 27 | 추가: record = selected[name] | |
| 28 | 추가: self.assertEqual(record["version"], version) | |
| 29 | 추가: self.assertEqual(record["license"], license_id) | |
| 30 | 추가: self.assertTrue(record["files"]) | |
| 31 | 추가: self.assertIn(f"Crate: {name} {version}\n", notice) | |
| 32 | 추가: for original in record["files"]: | |
| 33 | 추가: self.assertIn(original["text"], notice) | |
| 34 | 추가: self.assertIn(original["sha256"], notice) | |
| 35 | 추가: self.assertTrue({"bzip2-sys", "lzma-sys", "liblzma-sys", "xz2"}.isdisjoint(selected)) | |
| 36 | 추가: | |
| 37 | 추가: | |
| 38 | 추가: if __name__ == "__main__": | |
| 39 | 추가: unittest.main() |
| @@ -10,7 +10,7 @@ checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" | ||
| 10 | 10 | dependencies = [ |
| 11 | 11 | "cfg-if", |
| 12 | 12 | "cipher", |
| 13 | 삭제: "cpufeatures", | |
| 13 | 추가: "cpufeatures 0.2.17", | |
| 14 | 14 | "zeroize", |
| 15 | 15 | ] |
| 16 | 16 | |
| @@ -23,6 +23,24 @@ dependencies = [ | ||
| 23 | 23 | "generic-array", |
| 24 | 24 | ] |
| 25 | 25 | |
| 26 | 추가: [[package]] | |
| 27 | 추가: name = "block-buffer" | |
| 28 | 추가: version = "0.12.1" | |
| 29 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 30 | 추가: checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" | |
| 31 | 추가: dependencies = [ | |
| 32 | 추가: "hybrid-array", | |
| 33 | 추가: ] | |
| 34 | 추가: | |
| 35 | 추가: [[package]] | |
| 36 | 추가: name = "bzip2" | |
| 37 | 추가: version = "0.6.1" | |
| 38 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 39 | 추가: checksum = "f3a53fac24f34a81bc9954b5d6cfce0c21e18ec6959f44f56e8e90e4bb7c346c" | |
| 40 | 추가: dependencies = [ | |
| 41 | 추가: "libbz2-rs-sys", | |
| 42 | 추가: ] | |
| 43 | 추가: | |
| 26 | 44 | [[package]] |
| 27 | 45 | name = "cfg-if" |
| 28 | 46 | version = "1.0.5" |
| @@ -35,10 +53,16 @@ version = "0.4.4" | ||
| 35 | 53 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 36 | 54 | checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" |
| 37 | 55 | dependencies = [ |
| 38 | 삭제: "crypto-common", | |
| 56 | 추가: "crypto-common 0.1.7", | |
| 39 | 57 | "inout", |
| 40 | 58 | ] |
| 41 | 59 | |
| 60 | 추가: [[package]] | |
| 61 | 추가: name = "const-oid" | |
| 62 | 추가: version = "0.10.3" | |
| 63 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 64 | 추가: checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" | |
| 65 | 추가: | |
| 42 | 66 | [[package]] |
| 43 | 67 | name = "cpufeatures" |
| 44 | 68 | version = "0.2.17" |
| @@ -48,6 +72,15 @@ dependencies = [ | ||
| 48 | 72 | "libc", |
| 49 | 73 | ] |
| 50 | 74 | |
| 75 | 추가: [[package]] | |
| 76 | 추가: name = "cpufeatures" | |
| 77 | 추가: version = "0.3.1" | |
| 78 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 79 | 추가: checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" | |
| 80 | 추가: dependencies = [ | |
| 81 | 추가: "libc", | |
| 82 | 추가: ] | |
| 83 | 추가: | |
| 51 | 84 | [[package]] |
| 52 | 85 | name = "crypto-common" |
| 53 | 86 | version = "0.1.7" |
| @@ -58,17 +91,37 @@ dependencies = [ | ||
| 58 | 91 | "typenum", |
| 59 | 92 | ] |
| 60 | 93 | |
| 94 | 추가: [[package]] | |
| 95 | 추가: name = "crypto-common" | |
| 96 | 추가: version = "0.2.2" | |
| 97 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 98 | 추가: checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" | |
| 99 | 추가: dependencies = [ | |
| 100 | 추가: "hybrid-array", | |
| 101 | 추가: ] | |
| 102 | 추가: | |
| 61 | 103 | [[package]] |
| 62 | 104 | name = "digest" |
| 63 | 105 | version = "0.10.7" |
| 64 | 106 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 65 | 107 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" |
| 66 | 108 | dependencies = [ |
| 67 | 삭제: "block-buffer", | |
| 68 | 삭제: "crypto-common", | |
| 109 | 추가: "block-buffer 0.10.4", | |
| 110 | 추가: "crypto-common 0.1.7", | |
| 69 | 111 | "subtle", |
| 70 | 112 | ] |
| 71 | 113 | |
| 114 | 추가: [[package]] | |
| 115 | 추가: name = "digest" | |
| 116 | 추가: version = "0.11.3" | |
| 117 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 118 | 추가: checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" | |
| 119 | 추가: dependencies = [ | |
| 120 | 추가: "block-buffer 0.12.1", | |
| 121 | 추가: "const-oid", | |
| 122 | 추가: "crypto-common 0.2.2", | |
| 123 | 추가: ] | |
| 124 | 추가: | |
| 72 | 125 | [[package]] |
| 73 | 126 | name = "generic-array" |
| 74 | 127 | version = "0.14.7" |
| @@ -85,7 +138,16 @@ version = "0.12.1" | ||
| 85 | 138 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 86 | 139 | checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" |
| 87 | 140 | dependencies = [ |
| 88 | 삭제: "digest", | |
| 141 | 추가: "digest 0.10.7", | |
| 142 | 추가: ] | |
| 143 | 추가: | |
| 144 | 추가: [[package]] | |
| 145 | 추가: name = "hybrid-array" | |
| 146 | 추가: version = "0.4.15" | |
| 147 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 148 | 추가: checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" | |
| 149 | 추가: dependencies = [ | |
| 150 | 추가: "typenum", | |
| 89 | 151 | ] |
| 90 | 152 | |
| 91 | 153 | [[package]] |
| @@ -97,19 +159,34 @@ dependencies = [ | ||
| 97 | 159 | "generic-array", |
| 98 | 160 | ] |
| 99 | 161 | |
| 162 | 추가: [[package]] | |
| 163 | 추가: name = "libbz2-rs-sys" | |
| 164 | 추가: version = "0.2.6" | |
| 165 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 166 | 추가: checksum = "32f454fd6831a29c0e827ed075bca2a15be201bd57f4168f0fd1041124eab17e" | |
| 167 | 추가: | |
| 100 | 168 | [[package]] |
| 101 | 169 | name = "libc" |
| 102 | 170 | version = "0.2.191" |
| 103 | 171 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 104 | 172 | checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" |
| 105 | 173 | |
| 174 | 추가: [[package]] | |
| 175 | 추가: name = "lzma-rust2" | |
| 176 | 추가: version = "0.25.0" | |
| 177 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 178 | 추가: checksum = "ef1d73c59a56771343712b22ea5615092c612c16ba291c0979e3105dfeec4890" | |
| 179 | 추가: dependencies = [ | |
| 180 | 추가: "sha2 0.11.1", | |
| 181 | 추가: ] | |
| 182 | 추가: | |
| 106 | 183 | [[package]] |
| 107 | 184 | name = "pbkdf2" |
| 108 | 185 | version = "0.12.2" |
| 109 | 186 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 110 | 187 | checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" |
| 111 | 188 | dependencies = [ |
| 112 | 삭제: "digest", | |
| 189 | 추가: "digest 0.10.7", | |
| 113 | 190 | "hmac", |
| 114 | 191 | ] |
| 115 | 192 | |
| @@ -120,8 +197,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 120 | 197 | checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" |
| 121 | 198 | dependencies = [ |
| 122 | 199 | "cfg-if", |
| 123 | 삭제: "cpufeatures", | |
| 124 | 삭제: "digest", | |
| 200 | 추가: "cpufeatures 0.2.17", | |
| 201 | 추가: "digest 0.10.7", | |
| 125 | 202 | ] |
| 126 | 203 | |
| 127 | 204 | [[package]] |
| @@ -131,8 +208,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 131 | 208 | checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" |
| 132 | 209 | dependencies = [ |
| 133 | 210 | "cfg-if", |
| 134 | 삭제: "cpufeatures", | |
| 135 | 삭제: "digest", | |
| 211 | 추가: "cpufeatures 0.2.17", | |
| 212 | 추가: "digest 0.10.7", | |
| 213 | 추가: ] | |
| 214 | 추가: | |
| 215 | 추가: [[package]] | |
| 216 | 추가: name = "sha2" | |
| 217 | 추가: version = "0.11.1" | |
| 218 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 219 | 추가: checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" | |
| 220 | 추가: dependencies = [ | |
| 221 | 추가: "cfg-if", | |
| 222 | 추가: "cpufeatures 0.3.1", | |
| 223 | 추가: "digest 0.11.3", | |
| 136 | 224 | ] |
| 137 | 225 | |
| 138 | 226 | [[package]] |
| @@ -164,10 +252,12 @@ name = "zipelo-archive-worker" | ||
| 164 | 252 | version = "0.1.0" |
| 165 | 253 | dependencies = [ |
| 166 | 254 | "aes", |
| 255 | 추가: "bzip2", | |
| 167 | 256 | "hmac", |
| 257 | 추가: "lzma-rust2", | |
| 168 | 258 | "pbkdf2", |
| 169 | 259 | "sha1", |
| 170 | 삭제: "sha2", | |
| 260 | 추가: "sha2 0.10.9", | |
| 171 | 261 | "subtle", |
| 172 | 262 | "zeroize", |
| 173 | 263 | "zlib-rs", |
| @@ -0,0 +1,71 @@ | ||
| 1 | 추가: #[test] | |
| 2 | 추가: fn compressed_tar_opens_with_native_dialog_and_extracts_to_compound_stem() { | |
| 3 | 추가: use zipelo_ui_memory_app::archive_dialog::Purpose; | |
| 4 | 추가: for (kind, name) in [("bz2", "여행 자료.TaR.Bz2"), ("xz", "여행 자료.tAr.XZ")] { | |
| 5 | 추가: let scratch = Scratch::new(); | |
| 6 | 추가: let generated = std::process::Command::new("python3") | |
| 7 | 추가: .arg( | |
| 8 | 추가: Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 9 | 추가: .join("../../tests/rust-archive-worker/compressed_tar_cases.py"), | |
| 10 | 추가: ) | |
| 11 | 추가: .arg(&scratch.0) | |
| 12 | 추가: .arg(kind) | |
| 13 | 추가: .arg("normal") | |
| 14 | 추가: .output() | |
| 15 | 추가: .unwrap(); | |
| 16 | 추가: assert!( | |
| 17 | 추가: generated.status.success(), | |
| 18 | 추가: "{}", | |
| 19 | 추가: String::from_utf8_lossy(&generated.stderr) | |
| 20 | 추가: ); | |
| 21 | 추가: let archive = scratch.path(name); | |
| 22 | 추가: fs::rename(scratch.path("input"), &archive).unwrap(); | |
| 23 | 추가: let original = fs::read(&archive).unwrap(); | |
| 24 | 추가: let (factory, observed) = observed_factory(); | |
| 25 | 추가: let mut screen = Screen::new(factory); | |
| 26 | 추가: screen | |
| 27 | 추가: .dialogs | |
| 28 | 추가: .0 | |
| 29 | 추가: .borrow_mut() | |
| 30 | 추가: .answers | |
| 31 | 추가: .push_back(Some(vec![archive.clone()])); | |
| 32 | 추가: screen.click("열기"); | |
| 33 | 추가: screen.settle(); | |
| 34 | 추가: assert_eq!(screen.dialogs.0.borrow().requests[0].purpose, Purpose::Open); | |
| 35 | 추가: assert_eq!( | |
| 36 | 추가: screen.app.model.list_id.as_ref().unwrap().format, | |
| 37 | 추가: Format::Tar | |
| 38 | 추가: ); | |
| 39 | 추가: assert!( | |
| 40 | 추가: screen | |
| 41 | 추가: .app | |
| 42 | 추가: .model | |
| 43 | 추가: .entries | |
| 44 | 추가: .iter() | |
| 45 | 추가: .any(|e| e.name == "한글.txt") | |
| 46 | 추가: ); | |
| 47 | 추가: assert!(screen.app.begin_extract()); | |
| 48 | 추가: screen.settle(); | |
| 49 | 추가: let output = scratch.path("여행 자료"); | |
| 50 | 추가: assert_eq!( | |
| 51 | 추가: fs::read(output.join("folder/payload.bin")).unwrap(), | |
| 52 | 추가: fs::read(scratch.path("expected")).unwrap() | |
| 53 | 추가: ); | |
| 54 | 추가: assert_eq!(fs::read(output.join("한글.txt")).unwrap(), b"end"); | |
| 55 | 추가: assert!(output.join("empty").is_dir()); | |
| 56 | 추가: assert_eq!(fs::read(&archive).unwrap(), original); | |
| 57 | 추가: assert!( | |
| 58 | 추가: matches!(observed.borrow().starts.last(), Some(Start::Extract { | |
| 59 | 추가: destination, gzip_output_name: None, .. | |
| 60 | 추가: }) if destination == &output) | |
| 61 | 추가: ); | |
| 62 | 추가: let labels = screen | |
| 63 | 추가: .render(vec![]) | |
| 64 | 추가: .into_iter() | |
| 65 | 추가: .map(|(s, _)| s) | |
| 66 | 추가: .collect::<Vec<_>>() | |
| 67 | 추가: .join("\n"); | |
| 68 | 추가: assert!(labels.contains("압축을 풀었습니다"), "{labels}"); | |
| 69 | 추가: assert_reaped(&observed); | |
| 70 | 추가: } | |
| 71 | 추가: } |
| @@ -311,6 +311,7 @@ mod screen { | ||
| 311 | 311 | include!("password_flows.rs"); |
| 312 | 312 | include!("selection_flows.rs"); |
| 313 | 313 | include!("native_dialog_flows.rs"); |
| 314 | 추가: include!("compressed_tar_flows.rs"); | |
| 314 | 315 | |
| 315 | 316 | fn archive_flow(name: &str, format: Format) { |
| 316 | 317 | let scratch = Scratch::new(); |
| @@ -17,11 +17,21 @@ fn archive_filter_contains_every_case_variant_and_all_files_option() { | ||
| 17 | 17 | .into_iter() |
| 18 | 18 | .map(str::to_owned) |
| 19 | 19 | .collect::<BTreeSet<_>>(); |
| 20 | 삭제: assert_eq!( | |
| 21 | 삭제: filters[0].1.iter().cloned().collect::<BTreeSet<_>>(), | |
| 22 | 삭제: expected | |
| 23 | 삭제: ); | |
| 24 | 삭제: assert_eq!(filters[0].1.len(), expected.len()); | |
| 20 | 추가: let actual = filters[0].1.iter().cloned().collect::<BTreeSet<_>>(); | |
| 21 | 추가: assert!(expected.is_subset(&actual)); | |
| 22 | 추가: for extension in [ | |
| 23 | 추가: "tar.bz2", "TAR.BZ2", "TaR.bZ2", "tar.xz", "TAR.XZ", "tAr.Xz", | |
| 24 | 추가: ] { | |
| 25 | 추가: assert!(actual.contains(extension), "{extension}"); | |
| 26 | 추가: } | |
| 27 | 추가: assert_eq!(actual.len(), expected.len() + 64); | |
| 28 | 추가: assert_eq!(filters[0].1.len(), actual.len()); | |
| 29 | 추가: for extension in actual.difference(&expected) { | |
| 30 | 추가: assert!(matches!( | |
| 31 | 추가: extension.to_ascii_lowercase().as_str(), | |
| 32 | 추가: "tar.bz2" | "tar.xz" | |
| 33 | 추가: )); | |
| 34 | 추가: } | |
| 25 | 35 | assert_eq!(filters[1], ("모든 파일", vec!["*".to_owned()])); |
| 26 | 36 | } |
| 27 | 37 |
| @@ -320,7 +320,18 @@ fn duplicate_names_prevent_file_completion_assumptions() { | ||
| 320 | 320 | } |
| 321 | 321 | #[test] |
| 322 | 322 | fn default_names_and_middle_truncation_preserve_unicode() { |
| 323 | 삭제: assert_eq!(default_destination(&path("자료.tar.gz")), path("자료")); | |
| 323 | 추가: for name in [ | |
| 324 | 추가: "자료.tar.gz", | |
| 325 | 추가: "자료.tar.bz2", | |
| 326 | 추가: "자료.TAR.BZ2", | |
| 327 | 추가: "자료.TaR.xZ", | |
| 328 | 추가: "자료.tar.xz", | |
| 329 | 추가: ] { | |
| 330 | 추가: assert_eq!(default_destination(&path(name)), path("자료")); | |
| 331 | 추가: } | |
| 332 | 추가: for name in [".tar.bz2", ".TAR.XZ"] { | |
| 333 | 추가: assert_eq!(default_destination(&path(name)), path("압축 해제")); | |
| 334 | 추가: } | |
| 324 | 335 | assert_eq!(default_destination(&path("자료.zip")), path("자료")); |
| 325 | 336 | assert_eq!(middle_text("가나다라마바사아자차", 7), "가나다…아자차"); |
| 326 | 337 | assert_eq!(bytes_text(21), "21 B"); |
| @@ -100,7 +100,8 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() { | ||
| 100 | 100 | "uninstall-settings-error" => "Windows 설정을 열지 못했습니다", |
| 101 | 101 | "uninstall-ubuntu-missing" => "이전 앱을 복원할 수 없습니다", |
| 102 | 102 | "uninstall-ubuntu-unknown-user" => "사용자 기본 앱 설정은 변경하지 않습니다", |
| 103 | 삭제: "empty" => "압축파일", | |
| 103 | 추가: "empty" => "TAR.BZ2, TAR.XZ", | |
| 104 | 추가: "tar-bz2" | "tar-xz" => "읽어주세요.txt", | |
| 104 | 105 | "folder-empty" => "이 폴더는 비어 있습니다", |
| 105 | 106 | "dialog-error" => "파일 선택 창을 열 수 없습니다", |
| 106 | 107 | "extract-partial" => "일부 파일만 풀렸습니다", |
| @@ -123,6 +124,13 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() { | ||
| 123 | 124 | _ => "읽어주세요.txt", |
| 124 | 125 | }; |
| 125 | 126 | assert!(labels.contains(expected), "{}: {labels}", scenario.name); |
| 127 | 추가: if matches!(scenario.name, "tar-bz2" | "tar-xz") { | |
| 128 | 추가: assert!(app.model.entries.iter().all(|entry| !entry.encrypted)); | |
| 129 | 추가: assert_eq!( | |
| 130 | 추가: app.model.list_id.as_ref().unwrap().format, | |
| 131 | 추가: zipelo_ui_memory_app::archive_ui::Format::Tar | |
| 132 | 추가: ); | |
| 133 | 추가: } | |
| 126 | 134 | if scenario.name == "many-items" { |
| 127 | 135 | assert_eq!(app.model.entries.len(), 505); |
| 128 | 136 | } |
| @@ -23,6 +23,8 @@ macro_rules! catalog { | ||
| 23 | 23 | catalog! { |
| 24 | 24 | "empty" => "빈 첫 화면", |
| 25 | 25 | "archive" => "폴더와 파일이 있는 압축파일", |
| 26 | 추가: "tar-bz2" => "TAR.BZ2 목록과 자동 해제 폴더", | |
| 27 | 추가: "tar-xz" => "TAR.XZ 목록과 자동 해제 폴더", | |
| 26 | 28 | "folder" => "사진 하위 폴더", |
| 27 | 29 | "many-items" => "500개 항목과 세로 스크롤", |
| 28 | 30 | "selection" => "여러 파일과 폴더 선택", |
| @@ -220,10 +222,11 @@ impl Scenario { | ||
| 220 | 222 | if self.name == "empty" || self.name.starts_with("uninstall-") { |
| 221 | 223 | return app; |
| 222 | 224 | } |
| 223 | 삭제: let archive = base.join(if self.name == "gzip-conflict" { | |
| 224 | 삭제: "여행 자료.gz" | |
| 225 | 삭제: } else { | |
| 226 | 삭제: "여행 자료.zip" | |
| 225 | 추가: let archive = base.join(match self.name { | |
| 226 | 추가: "gzip-conflict" => "여행 자료.gz", | |
| 227 | 추가: "tar-bz2" => "여행 자료.TAR.BZ2", | |
| 228 | 추가: "tar-xz" => "여행 자료.TaR.Xz", | |
| 229 | 추가: _ => "여행 자료.zip", | |
| 227 | 230 | }); |
| 228 | 231 | app.model.archive = Some(archive.clone()); |
| 229 | 232 | app.model.entries = entries(self.name == "many-items"); |
| @@ -239,6 +242,15 @@ impl Scenario { | ||
| 239 | 242 | }); |
| 240 | 243 | app.model.confirmed = true; |
| 241 | 244 | match self.name { |
| 245 | 추가: "tar-bz2" | "tar-xz" => { | |
| 246 | 추가: app.model.list_id.as_mut().unwrap().format = Format::Tar; | |
| 247 | 추가: for entry in &mut app.model.entries { | |
| 248 | 추가: entry.encrypted = false; | |
| 249 | 추가: } | |
| 250 | 추가: app.destination = present::default_destination(&archive); | |
| 251 | 추가: app.automatic_destination = true; | |
| 252 | 추가: return app; | |
| 253 | 추가: } | |
| 242 | 254 | "archive" | "many-items" => return app, |
| 243 | 255 | "folder-empty" => { |
| 244 | 256 | app.browse_folder("빈 폴더"); |
| @@ -0,0 +1,29 @@ | ||
| 1 | 추가: #define _GNU_SOURCE | |
| 2 | 추가: #include <dlfcn.h> | |
| 3 | 추가: #include <errno.h> | |
| 4 | 추가: #include <fcntl.h> | |
| 5 | 추가: #include <stdlib.h> | |
| 6 | 추가: #include <string.h> | |
| 7 | 추가: #include <sys/stat.h> | |
| 8 | 추가: #include <sys/statvfs.h> | |
| 9 | 추가: #include <unistd.h> | |
| 10 | 추가: | |
| 11 | 추가: static int regular_calls; | |
| 12 | 추가: | |
| 13 | 추가: int fstatvfs(int fd, struct statvfs *value) { | |
| 14 | 추가: int (*original)(int, struct statvfs *) = dlsym(RTLD_NEXT, "fstatvfs"); | |
| 15 | 추가: int result = original(fd, value); | |
| 16 | 추가: const char *mode = getenv("ZIPELO_COMPRESSED_FAULT"); | |
| 17 | 추가: struct stat info; | |
| 18 | 추가: if (result || !mode || fstat(fd, &info) || !S_ISREG(info.st_mode)) return result; | |
| 19 | 추가: if (++regular_calls != 2) return result; | |
| 20 | 추가: int marker = open(getenv("ZIPELO_COMPRESSED_MARKER"), O_CREAT | O_EXCL | O_WRONLY, 0600); | |
| 21 | 추가: if (marker < 0) { errno = EIO; return -1; } | |
| 22 | 추가: close(marker); | |
| 23 | 추가: if (!strcmp(mode, "full")) { value->f_bavail = 0; return 0; } | |
| 24 | 추가: if (!strcmp(mode, "io")) { errno = EIO; return -1; } | |
| 25 | 추가: const char *release = getenv("ZIPELO_COMPRESSED_RELEASE"); | |
| 26 | 추가: for (int i = 0; i < 1000 && access(release, F_OK); i++) usleep(10000); | |
| 27 | 추가: if (access(release, F_OK)) { errno = EIO; return -1; } | |
| 28 | 추가: return result; | |
| 29 | 추가: } |
| @@ -0,0 +1,405 @@ | ||
| 1 | 추가: use super::*; | |
| 2 | 추가: | |
| 3 | 추가: fn fixture(kind: &str, case: &str) -> Scratch { | |
| 4 | 추가: let scratch = Scratch::new(); | |
| 5 | 추가: let output = Command::new("python3") | |
| 6 | 추가: .arg( | |
| 7 | 추가: PathBuf::from(env!("CARGO_MANIFEST_DIR")) | |
| 8 | 추가: .join("../../tests/rust-archive-worker/compressed_tar_cases.py"), | |
| 9 | 추가: ) | |
| 10 | 추가: .arg(&scratch.0) | |
| 11 | 추가: .arg(kind) | |
| 12 | 추가: .arg(case) | |
| 13 | 추가: .output() | |
| 14 | 추가: .unwrap(); | |
| 15 | 추가: assert!( | |
| 16 | 추가: output.status.success(), | |
| 17 | 추가: "{kind}/{case}: {}", | |
| 18 | 추가: String::from_utf8_lossy(&output.stderr) | |
| 19 | 추가: ); | |
| 20 | 추가: scratch | |
| 21 | 추가: } | |
| 22 | 추가: | |
| 23 | 추가: fn run_case(s: &Scratch, limits: Limits) -> Vec<Message> { | |
| 24 | 추가: extract( | |
| 25 | 추가: s, | |
| 26 | 추가: &fs::read(s.0.join("input")).unwrap(), | |
| 27 | 추가: None, | |
| 28 | 추가: Selection::All, | |
| 29 | 추가: None, | |
| 30 | 추가: limits, | |
| 31 | 추가: ) | |
| 32 | 추가: } | |
| 33 | 추가: | |
| 34 | 추가: fn no_output(s: &Scratch, events: &[Message], error: ErrorCode) { | |
| 35 | 추가: let result = terminal(events); | |
| 36 | 추가: assert_eq!(result.outcome, Outcome::Failed, "{events:?}"); | |
| 37 | 추가: assert_eq!(result.error, error, "{events:?}"); | |
| 38 | 추가: assert_eq!(result.created_count, 0); | |
| 39 | 추가: assert_eq!(result.publication, Publication::None); | |
| 40 | 추가: assert!( | |
| 41 | 추가: !events | |
| 42 | 추가: .iter() | |
| 43 | 추가: .any(|event| matches!(event, Message::Output { .. })) | |
| 44 | 추가: ); | |
| 45 | 추가: assert_eq!(fs::read_dir(s.0.join("output")).unwrap().count(), 0); | |
| 46 | 추가: assert!(!s.0.join("escape").exists()); | |
| 47 | 추가: } | |
| 48 | 추가: | |
| 49 | 추가: fn normal(kind: &str, case: &str) { | |
| 50 | 추가: let s = fixture(kind, case); | |
| 51 | 추가: let events = run_case(&s, Limits::default()); | |
| 52 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Completed, "{events:?}"); | |
| 53 | 추가: assert_eq!( | |
| 54 | 추가: fs::read(s.0.join("output/folder/payload.bin")).unwrap(), | |
| 55 | 추가: fs::read(s.0.join("expected")).unwrap() | |
| 56 | 추가: ); | |
| 57 | 추가: assert_eq!(fs::read(s.0.join("output/한글.txt")).unwrap(), b"end"); | |
| 58 | 추가: assert!(s.0.join("output/empty").is_dir()); | |
| 59 | 추가: } | |
| 60 | 추가: | |
| 61 | 추가: #[test] | |
| 62 | 추가: fn bzip2_reference_tar_and_concatenated_streams() { | |
| 63 | 추가: for case in ["normal", "multi"] { | |
| 64 | 추가: normal("bz2", case); | |
| 65 | 추가: } | |
| 66 | 추가: } | |
| 67 | 추가: | |
| 68 | 추가: #[test] | |
| 69 | 추가: fn xz_reference_tar_checks_filters_and_concatenated_streams() { | |
| 70 | 추가: for case in [ | |
| 71 | 추가: "normal", | |
| 72 | 추가: "multi", | |
| 73 | 추가: "multi-block", | |
| 74 | 추가: "multi-block-filters", | |
| 75 | 추가: "stored-chunks", | |
| 76 | 추가: "padding", | |
| 77 | 추가: "crc32", | |
| 78 | 추가: "sha256", | |
| 79 | 추가: "no-check", | |
| 80 | 추가: "filters", | |
| 81 | 추가: ] { | |
| 82 | 추가: normal("xz", case); | |
| 83 | 추가: } | |
| 84 | 추가: } | |
| 85 | 추가: | |
| 86 | 추가: #[test] | |
| 87 | 추가: fn compressed_empty_tar_is_valid() { | |
| 88 | 추가: for kind in ["bz2", "xz"] { | |
| 89 | 추가: let s = fixture(kind, "empty"); | |
| 90 | 추가: let events = run_case(&s, Limits::default()); | |
| 91 | 추가: assert_eq!( | |
| 92 | 추가: terminal(&events).outcome, | |
| 93 | 추가: Outcome::Completed, | |
| 94 | 추가: "{kind}: {events:?}" | |
| 95 | 추가: ); | |
| 96 | 추가: assert_eq!(terminal(&events).created_count, 0); | |
| 97 | 추가: assert_eq!(fs::read_dir(s.0.join("output")).unwrap().count(), 0); | |
| 98 | 추가: } | |
| 99 | 추가: } | |
| 100 | 추가: | |
| 101 | 추가: #[test] | |
| 102 | 추가: fn bzip2_truncation_corruption_and_trailing_data_never_publish() { | |
| 103 | 추가: for case in [ | |
| 104 | 추가: "truncated", | |
| 105 | 추가: "corrupt", | |
| 106 | 추가: "trailing", | |
| 107 | 추가: "multi-bad", | |
| 108 | 추가: "bad-tar", | |
| 109 | 추가: "raw", | |
| 110 | 추가: "empty-stream", | |
| 111 | 추가: ] { | |
| 112 | 추가: let s = fixture("bz2", case); | |
| 113 | 추가: let events = run_case(&s, Limits::default()); | |
| 114 | 추가: no_output(&s, &events, ErrorCode::Integrity); | |
| 115 | 추가: } | |
| 116 | 추가: } | |
| 117 | 추가: | |
| 118 | 추가: #[test] | |
| 119 | 추가: fn xz_truncation_corruption_and_trailing_data_never_publish() { | |
| 120 | 추가: for case in [ | |
| 121 | 추가: "truncated", | |
| 122 | 추가: "corrupt", | |
| 123 | 추가: "trailing", | |
| 124 | 추가: "multi-bad", | |
| 125 | 추가: "bad-tar", | |
| 126 | 추가: "raw", | |
| 127 | 추가: "empty-stream", | |
| 128 | 추가: "bad-padding", | |
| 129 | 추가: ] { | |
| 130 | 추가: let s = fixture("xz", case); | |
| 131 | 추가: let events = run_case(&s, Limits::default()); | |
| 132 | 추가: no_output(&s, &events, ErrorCode::Integrity); | |
| 133 | 추가: } | |
| 134 | 추가: } | |
| 135 | 추가: | |
| 136 | 추가: #[test] | |
| 137 | 추가: fn xz_index_sizes_cannot_cancel_between_streams() { | |
| 138 | 추가: let s = fixture("xz", "index-stream-sizes"); | |
| 139 | 추가: let events = run_case(&s, Limits::default()); | |
| 140 | 추가: no_output(&s, &events, ErrorCode::Integrity); | |
| 141 | 추가: } | |
| 142 | 추가: | |
| 143 | 추가: #[test] | |
| 144 | 추가: fn xz_index_sizes_cannot_cancel_between_blocks() { | |
| 145 | 추가: let s = fixture("xz", "index-block-sizes"); | |
| 146 | 추가: let events = run_case(&s, Limits::default()); | |
| 147 | 추가: no_output(&s, &events, ErrorCode::Integrity); | |
| 148 | 추가: } | |
| 149 | 추가: | |
| 150 | 추가: #[test] | |
| 151 | 추가: fn xz_index_unpadded_sizes_must_match_each_block() { | |
| 152 | 추가: let s = fixture("xz", "index-unpadded-sizes"); | |
| 153 | 추가: let events = run_case(&s, Limits::default()); | |
| 154 | 추가: no_output(&s, &events, ErrorCode::Integrity); | |
| 155 | 추가: } | |
| 156 | 추가: | |
| 157 | 추가: #[test] | |
| 158 | 추가: fn compressed_tar_bombs_stop_before_publication() { | |
| 159 | 추가: for kind in ["bz2", "xz"] { | |
| 160 | 추가: let s = fixture(kind, "bomb"); | |
| 161 | 추가: let events = run_case( | |
| 162 | 추가: &s, | |
| 163 | 추가: Limits { | |
| 164 | 추가: output: 256 * 1024, | |
| 165 | 추가: ..Limits::default() | |
| 166 | 추가: }, | |
| 167 | 추가: ); | |
| 168 | 추가: no_output(&s, &events, ErrorCode::Limit); | |
| 169 | 추가: } | |
| 170 | 추가: } | |
| 171 | 추가: | |
| 172 | 추가: #[test] | |
| 173 | 추가: fn xz_huge_dictionary_is_rejected_before_allocation() { | |
| 174 | 추가: let s = fixture("xz", "dictionary"); | |
| 175 | 추가: let events = run_case(&s, Limits::default()); | |
| 176 | 추가: no_output(&s, &events, ErrorCode::Limit); | |
| 177 | 추가: } | |
| 178 | 추가: | |
| 179 | 추가: #[test] | |
| 180 | 추가: fn compressed_tar_paths_and_links_keep_existing_guards() { | |
| 181 | 추가: for kind in ["bz2", "xz"] { | |
| 182 | 추가: for (case, error) in [ | |
| 183 | 추가: ("unsafe", ErrorCode::UnsafePath), | |
| 184 | 추가: ("link", ErrorCode::UnsafePath), | |
| 185 | 추가: ] { | |
| 186 | 추가: let s = fixture(kind, case); | |
| 187 | 추가: let events = run_case(&s, Limits::default()); | |
| 188 | 추가: no_output(&s, &events, error); | |
| 189 | 추가: } | |
| 190 | 추가: } | |
| 191 | 추가: } | |
| 192 | 추가: | |
| 193 | 추가: #[test] | |
| 194 | 추가: fn compressed_tar_list_identity_and_selection() { | |
| 195 | 추가: for kind in ["bz2", "xz"] { | |
| 196 | 추가: let s = fixture(kind, "normal"); | |
| 197 | 추가: let events = execute(Start { | |
| 198 | 추가: action: Action::List { | |
| 199 | 추가: archive: s.path("input"), | |
| 200 | 추가: }, | |
| 201 | 추가: limits: Limits::default(), | |
| 202 | 추가: }); | |
| 203 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Completed, "{events:?}"); | |
| 204 | 추가: let token = events | |
| 205 | 추가: .iter() | |
| 206 | 추가: .find_map(|event| match event { | |
| 207 | 추가: Message::ListEnd { list_id, .. } => Some(list_id.clone()), | |
| 208 | 추가: _ => None, | |
| 209 | 추가: }) | |
| 210 | 추가: .unwrap(); | |
| 211 | 추가: assert_eq!(token.format, Format::Tar); | |
| 212 | 추가: let bytes = fs::read(s.0.join("input")).unwrap(); | |
| 213 | 추가: let events = extract( | |
| 214 | 추가: &s, | |
| 215 | 추가: &bytes, | |
| 216 | 추가: None, | |
| 217 | 추가: Selection::EntryIds(vec![2]), | |
| 218 | 추가: Some(token), | |
| 219 | 추가: Limits::default(), | |
| 220 | 추가: ); | |
| 221 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Completed, "{events:?}"); | |
| 222 | 추가: assert_eq!(fs::read(s.0.join("output/한글.txt")).unwrap(), b"end"); | |
| 223 | 추가: assert!(!s.0.join("output/folder").exists()); | |
| 224 | 추가: } | |
| 225 | 추가: } | |
| 226 | 추가: | |
| 227 | 추가: #[test] | |
| 228 | 추가: fn compressed_tar_entry_quota_is_preserved() { | |
| 229 | 추가: for kind in ["bz2", "xz"] { | |
| 230 | 추가: let s = fixture(kind, "normal"); | |
| 231 | 추가: let events = run_case( | |
| 232 | 추가: &s, | |
| 233 | 추가: Limits { | |
| 234 | 추가: entries: 1, | |
| 235 | 추가: ..Limits::default() | |
| 236 | 추가: }, | |
| 237 | 추가: ); | |
| 238 | 추가: no_output(&s, &events, ErrorCode::Limit); | |
| 239 | 추가: } | |
| 240 | 추가: } | |
| 241 | 추가: | |
| 242 | 추가: #[cfg(target_os = "linux")] | |
| 243 | 추가: mod linux { | |
| 244 | 추가: use super::*; | |
| 245 | 추가: use std::{ | |
| 246 | 추가: io::Read, | |
| 247 | 추가: time::{Duration, Instant}, | |
| 248 | 추가: }; | |
| 249 | 추가: | |
| 250 | 추가: struct Running(std::process::Child); | |
| 251 | 추가: impl Drop for Running { | |
| 252 | 추가: fn drop(&mut self) { | |
| 253 | 추가: let _ = self.0.kill(); | |
| 254 | 추가: let _ = self.0.wait(); | |
| 255 | 추가: } | |
| 256 | 추가: } | |
| 257 | 추가: | |
| 258 | 추가: fn inject(s: &Scratch, mode: &str) -> (Running, Writer<std::process::ChildStdin>) { | |
| 259 | 추가: let library = s.0.join("compressed_fault.so"); | |
| 260 | 추가: assert!( | |
| 261 | 추가: Command::new("cc") | |
| 262 | 추가: .args(["-shared", "-fPIC", "-O2", "-Wall", "-Wextra", "-Werror"]) | |
| 263 | 추가: .arg( | |
| 264 | 추가: PathBuf::from(env!("CARGO_MANIFEST_DIR")) | |
| 265 | 추가: .join("../../tests/rust-archive-worker/compressed_fault.c") | |
| 266 | 추가: ) | |
| 267 | 추가: .arg("-ldl") | |
| 268 | 추가: .arg("-o") | |
| 269 | 추가: .arg(&library) | |
| 270 | 추가: .status() | |
| 271 | 추가: .unwrap() | |
| 272 | 추가: .success() | |
| 273 | 추가: ); | |
| 274 | 추가: let bytes = fs::read(s.0.join("input")).unwrap(); | |
| 275 | 추가: let preparation = extract( | |
| 276 | 추가: s, | |
| 277 | 추가: &bytes, | |
| 278 | 추가: None, | |
| 279 | 추가: Selection::EntryIds(vec![999]), | |
| 280 | 추가: None, | |
| 281 | 추가: Limits::default(), | |
| 282 | 추가: ); | |
| 283 | 추가: assert_ne!(terminal(&preparation).outcome, Outcome::Completed); | |
| 284 | 추가: let mut command = s.worker(); | |
| 285 | 추가: command | |
| 286 | 추가: .env("LD_PRELOAD", library) | |
| 287 | 추가: .env("ZIPELO_COMPRESSED_FAULT", mode) | |
| 288 | 추가: .env("ZIPELO_COMPRESSED_MARKER", s.0.join("paused")) | |
| 289 | 추가: .env("ZIPELO_COMPRESSED_RELEASE", s.0.join("release")) | |
| 290 | 추가: .stdin(Stdio::piped()) | |
| 291 | 추가: .stdout(Stdio::piped()) | |
| 292 | 추가: .stderr(Stdio::piped()); | |
| 293 | 추가: let mut child = command.spawn().unwrap(); | |
| 294 | 추가: let mut writer = Writer::new(child.stdin.take().unwrap(), 17); | |
| 295 | 추가: writer | |
| 296 | 추가: .send(&Message::Start(Start { | |
| 297 | 추가: action: Action::Extract { | |
| 298 | 추가: archive: s.path("input"), | |
| 299 | 추가: destination: s.path("output"), | |
| 300 | 추가: selection: Selection::All, | |
| 301 | 추가: list_id: None, | |
| 302 | 추가: gzip_output_name: None, | |
| 303 | 추가: }, | |
| 304 | 추가: limits: Limits::default(), | |
| 305 | 추가: })) | |
| 306 | 추가: .unwrap(); | |
| 307 | 추가: (Running(child), writer) | |
| 308 | 추가: } | |
| 309 | 추가: | |
| 310 | 추가: fn finish(child: &mut Running) -> Vec<Message> { | |
| 311 | 추가: drop(child.0.stdin.take()); | |
| 312 | 추가: let mut out = child.0.stdout.take().unwrap(); | |
| 313 | 추가: let mut err = child.0.stderr.take().unwrap(); | |
| 314 | 추가: let mut bytes = Vec::new(); | |
| 315 | 추가: out.read_to_end(&mut bytes).unwrap(); | |
| 316 | 추가: let mut errors = Vec::new(); | |
| 317 | 추가: err.read_to_end(&mut errors).unwrap(); | |
| 318 | 추가: assert!(child.0.wait().unwrap().success()); | |
| 319 | 추가: assert!(errors.is_empty(), "{errors:?}"); | |
| 320 | 추가: let mut reader = Reader::new(bytes.as_slice()); | |
| 321 | 추가: let mut events = Vec::new(); | |
| 322 | 추가: while let Some((_, _, event)) = reader.read().unwrap() { | |
| 323 | 추가: events.push(event); | |
| 324 | 추가: } | |
| 325 | 추가: events | |
| 326 | 추가: } | |
| 327 | 추가: | |
| 328 | 추가: #[test] | |
| 329 | 추가: fn compressed_tar_codec_space_failure_never_publishes() { | |
| 330 | 추가: for kind in ["bz2", "xz"] { | |
| 331 | 추가: for (mode, error) in [("full", ErrorCode::DiskFull), ("io", ErrorCode::Io)] { | |
| 332 | 추가: let s = fixture(kind, "normal"); | |
| 333 | 추가: let (mut child, writer) = inject(&s, mode); | |
| 334 | 추가: drop(writer); | |
| 335 | 추가: let events = finish(&mut child); | |
| 336 | 추가: assert!(s.0.join("paused").exists()); | |
| 337 | 추가: no_output(&s, &events, error); | |
| 338 | 추가: } | |
| 339 | 추가: } | |
| 340 | 추가: } | |
| 341 | 추가: | |
| 342 | 추가: #[test] | |
| 343 | 추가: fn compressed_tar_cancels_during_decode_and_cleans_staging() { | |
| 344 | 추가: for kind in ["bz2", "xz"] { | |
| 345 | 추가: let s = fixture(kind, "normal"); | |
| 346 | 추가: let (mut child, mut writer) = inject(&s, "pause"); | |
| 347 | 추가: let deadline = Instant::now() + Duration::from_secs(10); | |
| 348 | 추가: while !s.0.join("paused").exists() { | |
| 349 | 추가: assert!(Instant::now() < deadline, "decoder did not pause"); | |
| 350 | 추가: std::thread::sleep(Duration::from_millis(5)); | |
| 351 | 추가: } | |
| 352 | 추가: writer.send(&Message::Cancel).unwrap(); | |
| 353 | 추가: drop(writer); | |
| 354 | 추가: std::thread::sleep(Duration::from_millis(25)); | |
| 355 | 추가: fs::write(s.0.join("release"), b"").unwrap(); | |
| 356 | 추가: let events = finish(&mut child); | |
| 357 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Cancelled, "{events:?}"); | |
| 358 | 추가: assert_eq!(terminal(&events).created_count, 0); | |
| 359 | 추가: assert_eq!(fs::read_dir(s.0.join("output")).unwrap().count(), 0); | |
| 360 | 추가: assert!( | |
| 361 | 추가: !events | |
| 362 | 추가: .iter() | |
| 363 | 추가: .any(|event| matches!(event, Message::Output { .. })) | |
| 364 | 추가: ); | |
| 365 | 추가: } | |
| 366 | 추가: } | |
| 367 | 추가: } | |
| 368 | 추가: | |
| 369 | 추가: #[test] | |
| 370 | 추가: fn xz_index_and_footer_claims_are_checked_before_publication() { | |
| 371 | 추가: for (case, error) in [ | |
| 372 | 추가: ("index-size", ErrorCode::Integrity), | |
| 373 | 추가: ("footer-offset", ErrorCode::Integrity), | |
| 374 | 추가: ("index-huge", ErrorCode::Limit), | |
| 375 | 추가: ] { | |
| 376 | 추가: let s = fixture("xz", case); | |
| 377 | 추가: let events = run_case(&s, Limits::default()); | |
| 378 | 추가: no_output(&s, &events, error); | |
| 379 | 추가: } | |
| 380 | 추가: } | |
| 381 | 추가: | |
| 382 | 추가: #[test] | |
| 383 | 추가: fn compressed_tar_output_quota_boundary() { | |
| 384 | 추가: for kind in ["bz2", "xz"] { | |
| 385 | 추가: for below in [false, true] { | |
| 386 | 추가: let s = fixture(kind, "normal"); | |
| 387 | 추가: let size: u64 = fs::read_to_string(s.0.join("plain-size")) | |
| 388 | 추가: .unwrap() | |
| 389 | 추가: .parse() | |
| 390 | 추가: .unwrap(); | |
| 391 | 추가: let events = run_case( | |
| 392 | 추가: &s, | |
| 393 | 추가: Limits { | |
| 394 | 추가: output: size - u64::from(below), | |
| 395 | 추가: ..Limits::default() | |
| 396 | 추가: }, | |
| 397 | 추가: ); | |
| 398 | 추가: if below { | |
| 399 | 추가: no_output(&s, &events, ErrorCode::Limit); | |
| 400 | 추가: } else { | |
| 401 | 추가: assert_eq!(terminal(&events).outcome, Outcome::Completed, "{events:?}"); | |
| 402 | 추가: } | |
| 403 | 추가: } | |
| 404 | 추가: } | |
| 405 | 추가: } |
Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기