team-ljyzipelo

공개

Merge branch 'feat/7z-split-create' into feat/search-esc-7z-split-logging

# Conflicts:
#	README.md
#	tests/rust-app-ui/scenario_tests.rs
작성자
LeeJunyoung
작성 시각
커밋
3ac206983006af63b0348f39d9374eab70f0216b
이 시점의 파일 보기

변경된 파일 24개

+1,209-36
수정README.md+3-2
@@ -46,8 +46,9 @@ Ubuntu에서는 [.deb 설치 파일](https://github.com/Team-LJY/zipelo/releases
4646아래 변경은 소스에 반영됐지만 위에서 받는 v0.1.0 설치 파일에는 포함되지 않습니다.
4747
4848- **파일 내용 미리보기:** 파일 하나를 고른 뒤 [미리보기]를 눌러 UTF-8 텍스트와 정적 PNG/JPEG를 읽기 전용으로 봅니다. 텍스트는 1 MiB, 이미지 파일은 8 MiB까지이며 이미지 가로와 세로는 각각 8,192픽셀, 전체는 1,600만 픽셀까지입니다([PR125](https://github.com/Team-LJY/zipelo/pull/125)).
49삭제: - **분할 7z 풀기:** 모든 조각을 같은 폴더에 모으고 `.7z.001`을 열면 목록 보기와 풀기를 할 수 있습니다. 조각은 최대 999개이며 분할 파일의 미리보기와 분할 압축 만들기는 지원하지 않습니다([PR126](https://github.com/Team-LJY/zipelo/pull/126)).
49추가: - **분할 7z 풀기:** 모든 조각을 같은 폴더에 모으고 `.7z.001`을 열면 목록 보기와 풀기를 할 수 있습니다. 조각은 최대 999개이며 분할 파일의 미리보기는 지원하지 않습니다([PR126](https://github.com/Team-LJY/zipelo/pull/126)).
5050- **7z 만들기:** 만들기 화면에서 ZIP 또는 7z를 선택합니다. 7z는 LZMA2 방식으로 만들며 암호를 설정하려면 ZIP을 선택하세요([PR127](https://github.com/Team-LJY/zipelo/pull/127)).
51추가: - **분할 7z 만들기:** 7z를 고른 뒤 [쪼갤 용량 설정]을 켜고 볼륨 크기(1 MB 이상, MB/GB)를 입력하면 `이름.7z.001`, `이름.7z.002` … 로 나누어 저장합니다. 볼륨은 최대 999개이며 7-Zip과 Zipelo에서 `.001`을 열어 풀 수 있습니다. 같은 이름의 조각이 이미 있으면 만들지 않고, 실패하거나 취소하면 만든 조각을 모두 지웁니다.
5152- **손상 ZIP 복구:** 4 GiB 이하 단일 ZIP32의 검증 가능한 비암호화 Store/Deflate 항목을 별도 ZIP으로 저장합니다. 원본은 고치지 않으며 일부만 복구되거나 복구할 수 없는 파일도 있습니다([PR128](https://github.com/Team-LJY/zipelo/pull/128)).
5253- **암호 7z 풀기:** `7z a -p`로 만든 AES-256 암호 7z와 분할 7z(`.7z.001`)의 목록 보기와 풀기를 지원합니다. 파일 이름까지 암호화한 7z는 목록을 읽을 때 암호를 묻습니다. 틀린 암호는 세 번까지 다시 입력할 수 있으며 잘못 풀린 파일을 저장하지 않습니다.
5354- **같은 이름의 파일 처리:** 덮어쓰기, 건너뛰기, 이름 바꿔 저장을 선택하고 나머지 파일에도 적용할 수 있습니다([PR114](https://github.com/Team-LJY/zipelo/pull/114)).
@@ -55,7 +56,7 @@ Ubuntu에서는 [.deb 설치 파일](https://github.com/Team-LJY/zipelo/releases
5556- **큰 작업 허용과 압축 폭탄 대응:** 기본 16 GiB를 넘는 작업은 사용자 허용 후 최대 64 GiB까지 진행할 수 있습니다. 항목 수, 압축률, 진행 시간과 여유 공간 등 안전 제한은 계속 적용됩니다([PR121](https://github.com/Team-LJY/zipelo/pull/121)).
5657- **Ubuntu X11 실행에 필요한 구성 요소:** 새 `.deb`는 빠져 있던 라이브러리를 설치 의존성에 포함해 X11 시작 오류를 해결했습니다([PR122](https://github.com/Team-LJY/zipelo/pull/122)).
5758
58삭제: **남은 한계:** 압축된 TAR(TAR.GZ, TAR.BZ2, TAR.XZ)은 기본 16 GiB, 승인 후 요청한 상한(최대 64 GiB)을 따릅니다. 이때 파일 내용뿐 아니라 TAR 헤더와 패딩도 계산하므로 파일 크기 합계보다 먼저 한도에 도달할 수 있습니다. RAR 압축과 해제, 암호화 7z 만들기, solid 방식의 7z 만들기, 분할 ZIP, 분할 압축 만들기와 분할 파일 미리보기는 지원하지 않습니다. ZIP 복구는 4 GiB 초과, ZIP64, 분할, SFX와 암호화된 내용 등을 지원하지 않으며 모든 손상을 복구하지는 못합니다.
59추가: **남은 한계:** 압축된 TAR(TAR.GZ, TAR.BZ2, TAR.XZ)은 기본 16 GiB, 승인 후 요청한 상한(최대 64 GiB)을 따릅니다. 이때 파일 내용뿐 아니라 TAR 헤더와 패딩도 계산하므로 파일 크기 합계보다 먼저 한도에 도달할 수 있습니다. RAR 압축과 해제, 암호화 7z 만들기, solid 방식의 7z 만들기, 분할 ZIP과 분할 ZIP 만들기, 분할 파일 미리보기는 지원하지 않습니다. 분할 압축은 7z로만 만들 수 있습니다. ZIP 복구는 4 GiB 초과, ZIP64, 분할, SFX와 암호화된 내용 등을 지원하지 않으며 모든 손상을 복구하지는 못합니다.
5960
6061main `3a77cfd`는 Windows 11 Pro build 26300과 Ubuntu 26.04.1 Wayland/X11에서 네 새 기능, 잘못된 암호 재시도와 덮어 설치를 확인했습니다. 실패 시 출력 정리 보강(PR130)은 이후 `cd45eab`로 병합됐으며 해당 수정 후 플랫폼 실기는 재실행하지 않았습니다. 사용자 요청에 따라 v0.2는 로컬 빌드만 허용됐으며 게시하지 않습니다. 구현 범위와 미검증 항목은 [v0.2 릴리스 노트 초안](docs/release-notes-v0.2.md)을 참고하세요.
6162
수정docs/ui-scenario-guide.md+6-1
@@ -194,7 +194,7 @@ Ubuntu 제거 안내는 패키지 관리자 터미널 출력입니다. 이전
194194- split-first-volume: .7z.002 등 선택 시 필요한 .001의 정확한 이름 안내. 자동으로 다른 파일을 열지 않음.
195195- split-missing-volume: 확정된 중간 누락의 파일명과 같은 폴더에 모든 조각을 모은 뒤 .001을 다시 여는 방법 안내.
196196- split-incomplete: 불완전하거나 손상된 묶음 안내. 마지막 누락 파일명을 추측하지 않음.
197삭제: - split-unsupported: 실제 분할 ZIP의 UnsupportedFeature 오류로 분할 ZIP, RAR과 분할 압축 만들기 미지원 안내를 표시한다. UnsupportedFormat도 같은 안내를 사용한다.
197추가: - split-unsupported: 실제 분할 ZIP의 UnsupportedFeature 오류로 분할 ZIP과 RAR 미지원 안내를 표시한다. UnsupportedFormat도 같은 안내를 사용한다.
198198- split-source-changed: 목록 이후 조각 변경 시 다시 열기 안내.
199199
200200운영체제 기본 열기 창에서 같은 폴더의 첫 조각 `.7z.001`을 선택한다. 분할 묶음은 최대 999개이며 목록 열람 성공은 전체 데이터 무결성 검증 완료를 뜻하지 않는다. 실제 분할 파일 처리는 작업자 구현 후 독립 도구 표본으로 확인한다. Windows와 Wayland에서 첫 조각 선택, 누락 이름, .001 재시도 안내와 닫기를 확인하며, 위 디자인 상황은 실제 파일 검증을 대신하지 않는다.
@@ -207,9 +207,14 @@ Ubuntu 제거 안내는 패키지 관리자 터미널 출력입니다. 이전
207207- create-sevenzip-error: 7z 저장 실패와 재시도.
208208- create-sevenzip-cancelled: 게시 전 취소 완료와 출력 없음.
209209- create-sevenzip-resource: 7z 생성의 큰 작업 허용 질문.
210추가: - create-sevenzip-split: 7z를 고르면 암호 안내 아래에 보이는 "쪼갤 용량 설정" 체크와 볼륨 크기 칸(정수)과 MB/GB 선택, `이름.7z.001, 이름.7z.002 …` 안내와 최대 999개 안내.
211추가: - create-sevenzip-split-invalid: 0처럼 1 MB보다 작거나 정수가 아닌 볼륨 크기의 빨간 안내와 비활성 압축하기 버튼.
212추가: - create-sevenzip-split-complete: 볼륨 세 개로 나눈 7z의 완료, 첫 볼륨(`.7z.001`) 경로와 볼륨 수 안내.
210213
2112147z를 선택하면 입력한 ZIP 암호와 실행 취소 기록을 지우며, ZIP으로 돌아와도 암호를 복원하지 않는다. 기본 저장 창은 .7z를 제안하며 암호가 필요하면 ZIP을 선택한다. 이 상황들은 가짜 작업자로 화면을 구성하므로 실제 7z 생성과 독립 도구 호환 시험을 대신하지 않는다.
212215
216추가: 쪼갤 용량은 7z에서만 보이며 1 MB = 1,048,576바이트로 계산한다. 저장 창에서 `이름.7z`를 고르면 같은 폴더에 `이름.7z.001`부터 차례로 만들고 `이름.7z` 자체는 만들지 않는다. 같은 폴더에 `이름.7z.<숫자>`가 하나라도 있으면 분할 읽기가 한 묶음으로 보므로 시작하지 않는다. 작업자는 모든 볼륨을 임시 파일로 쓴 뒤 한 번에 게시하며, 중간에 실패하거나 취소하면 이미 게시한 볼륨까지 지운다. 볼륨이 999개를 넘으면 한도 오류로 끝나고 쪼갤 용량을 늘리라고 안내한다. 실제 볼륨 크기와 분할 읽기 왕복은 tests/rust-archive-worker/seven_zip_split_create.rs에서 확인한다.
217추가:
213218### ZIP 복구
214219
215220손상 오류에서 "복구본 저장 위치 선택"을 누르면 운영체제 기본 저장 창이 열립니다.
수정experiments/rust-archive-worker/README.md+1-0
@@ -84,6 +84,7 @@ Python 표준 bz2, lzma와 tarfile로 독립 생성 및 해제한 결과의 SHA2
8484- lzma-rust2 =0.25.0의 std,xz,encoder만 사용합니다. encoder 기능은 추가 전이 의존성이 없고 Apache-2.0 원문은 기존 packaging/licenses.py 고지에 포함합니다. tests/release-packages/test_compressed_tar_licenses.py에서 실제 원문과 해시, 고정 버전 및 기능을 확인합니다. 기본/optimization 기능과 liblzma 개발 의존성은 제품에 포함하지 않습니다.
8585- 2026-11-14 OSV에 lzma-rust2 0.25.0을 조회했을 때 알려진 권고가 반환되지 않았습니다. RustSec 패키지명 검색도 결과가 없었으며 전체 의존성 감사나 취약점 부재를 뜻하지 않습니다. 정확한 질의와 결과는 PR의 검증 기록에 남깁니다.
8686- tests/rust-archive-worker/seven_zip_create_fields.rs와 seven_zip_create_runtime.rs는 정수/비트맵/버퍼 경계, 원본/목적지 변경, 자원 승인, 취소와 저장 실패를 검사합니다. ZIPELO_TEST_7ZIP에 독립 7-Zip 실행 파일을 지정하면 실제 test/list/extract와 SHA256/구조 대조도 수행합니다. 도구를 지정하지 않은 실행은 독립 7-Zip 검증 근거가 아닙니다. 1 GiB 메모리 회귀는 Linux에서 실행합니다. Windows/Wayland 실제 생성 통합 검증과 독립 리뷰는 별도입니다.
87추가: - CreateSevenZip의 volume_size가 있으면 완성한 7z를 그 크기(최소 1 MiB)로 나눠 `이름.7z.001`부터 최대 999개 볼륨으로 게시합니다. 같은 폴더에 `이름.7z.<숫자>`가 하나라도 있으면 Conflict로 거부하고, 모든 볼륨을 임시 파일로 쓴 뒤 한 번의 확정 단계로 링크하며 게시 중 실패하면 이미 게시한 볼륨을 지웁니다. tests/rust-archive-worker/seven_zip_split_create.rs가 볼륨 크기, 분할 읽기 왕복, 이름 충돌, 취소와 게시 중 충돌의 되돌리기를 검사하며 ZIPELO_TEST_7ZIP이 있으면 `7z t 이름.7z.001`도 실행합니다.
8788
8889## ZIP 생성 입력
8990
수정experiments/rust-archive-worker/src/create_sources.rs+16-5
@@ -208,27 +208,37 @@ impl Planned {
208208 return Err(ErrorCode::SourceChanged);
209209 }
210210 // 게시 임시 파일의 부모만 시각 대신 원래 항목과 소유 객체를 대조함.
211추가: // 분할 볼륨처럼 임시 파일이 여럿이면 모두 정확히 한 번씩 보여야 함.
212추가: let owned: Vec<(&str, &SourceObject)> =
213추가: std::iter::once((temporary.name.as_str(), &temporary.object))
214추가: .chain(
215추가: temporary
216추가: .others
217추가: .iter()
218추가: .map(|(name, object)| (name.as_str(), object)),
219추가: )
220추가: .collect();
221추가: let mut seen = vec![false; owned.len()];
211222 let mut count = 0;
212삭제: let mut found = false;
213223 for entry in input.children(&self.path)? {
214224 check.check()?;
215225 let name = entry.map_err(crate::space::io_error)?.file_name();
216226 let name = name.to_str().ok_or(ErrorCode::SourceChanged)?;
217삭제: if name == temporary.name {
227추가: if let Some(index) = owned.iter().position(|(owned, _)| *owned == name) {
218228 let child = input
219229 .open_child(&self.path, name)
220230 .map_err(|_| ErrorCode::SourceChanged)?;
221삭제: if found
231추가: if seen[index]
222232 || !child
223233 .file
224234 .metadata()
225235 .map_err(crate::space::io_error)?
226236 .is_file()
227삭제: || filesystem::object(&child.file)? != temporary.object
237추가: || filesystem::object(&child.file)? != *owned[index].1
228238 {
229239 return Err(ErrorCode::SourceChanged);
230240 }
231삭제: found = true;
241추가: seen[index] = true;
232242 } else if self
233243 .children
234244 .binary_search_by(|leaf| leaf.as_str().cmp(name))
@@ -241,6 +251,7 @@ impl Planned {
241251 crate::resources::completed(Ok(()), check)?;
242252 }
243253 let after = input.file.metadata().map_err(crate::space::io_error)?;
254추가: let found = seen.iter().all(|seen| *seen);
244255 if !found || count != self.children.len() || before.modified().ok() != after.modified().ok()
245256 {
246257 return Err(ErrorCode::SourceChanged);
수정experiments/rust-archive-worker/src/filesystem.rs+205-0
@@ -935,6 +935,8 @@ pub(crate) struct PublicationTemp {
935935 pub parent: SourceObject,
936936 pub name: String,
937937 pub object: SourceObject,
938추가: /// 분할 볼륨처럼 한 번에 게시하는 나머지 임시 파일 (이름, 객체).
939추가: pub others: Vec<(String, SourceObject)>,
938940}
939941pub(crate) enum PublishStep {
940942 Check,
@@ -998,6 +1000,7 @@ pub(crate) fn publish_reader_steps(
9981000 parent: object(dir.handle())?,
9991001 name: temp.clone(),
10001002 object: object(&file)?,
1003추가: others: Vec::new(),
10011004 });
10021005 completed(Ok(()), &mut PublicationMonitor(check))?;
10031006 completed(
@@ -1137,3 +1140,205 @@ pub(crate) fn publish_reader_steps(
11371140 result.error = prepared.err();
11381141 result
11391142}
1143추가:
1144추가: /// 여러 파일을 한 묶음으로 게시한 결과. `created`는 게시된 채 남은 이름.
1145추가: pub(crate) struct PublishedSet {
1146추가: pub created: Vec<String>,
1147추가: pub uncertain: bool,
1148추가: pub error: Option<ErrorCode>,
1149추가: pub durability: Durability,
1150추가: pub cleanup: Cleanup,
1151추가: pub retained: Vec<String>,
1152추가: }
1153추가: struct Staged {
1154추가: temp: String,
1155추가: object: Option<SourceObject>,
1156추가: }
1157추가: /// 분할 볼륨을 같은 폴더에 모두 임시 파일로 쓴 뒤 한 번의 확정 단계로 게시함.
1158추가: /// 쓰기 중 실패나 취소는 임시 파일만 지우고, 게시 중 실패는 이미 게시한 볼륨을 되돌림.
1159추가: /// 이름은 `root` 바로 아래 파일 이름이어야 하고 기존 이름은 덮어쓰지 않음.
1160추가: pub(crate) fn publish_set_steps(
1161추가: root: &Dir,
1162추가: files: &[(String, u64)],
1163추가: data: &mut impl Read,
1164추가: check: &mut impl FnMut(PublishStep) -> Result<()>,
1165추가: ) -> PublishedSet {
1166추가: let mut result = PublishedSet {
1167추가: created: Vec::new(),
1168추가: uncertain: false,
1169추가: error: None,
1170추가: durability: Durability::NotApplicable,
1171추가: cleanup: Cleanup::Complete,
1172추가: retained: Vec::new(),
1173추가: };
1174추가: let mut staged: Vec<Staged> = Vec::new();
1175추가: let mut linked = 0usize;
1176추가: let mut finish = (|| {
1177추가: if files.is_empty() {
1178추가: return Err(ErrorCode::InvalidRequest);
1179추가: }
1180추가: for (name, _) in files {
1181추가: valid_name(name, false)?;
1182추가: if name.contains('/') {
1183추가: return Err(ErrorCode::InvalidRequest);
1184추가: }
1185추가: }
1186추가: let parent = object(root.handle())?;
1187추가: let mut buffer = zeroize::Zeroizing::new([0; 65536]);
1188추가: for (_, length) in files {
1189추가: check(PublishStep::Check)?;
1190추가: let temp = format!(
1191추가: ".zipelo-{}-{}.tmp",
1192추가: std::process::id(),
1193추가: TEMP.fetch_add(1, Ordering::Relaxed)
1194추가: );
1195추가: let mut file = root.create(&temp).map_err(|e| {
1196추가: if e.kind() == std::io::ErrorKind::AlreadyExists {
1197추가: ErrorCode::Conflict
1198추가: } else {
1199추가: crate::space::io_error(e)
1200추가: }
1201추가: })?;
1202추가: staged.push(Staged { temp, object: None });
1203추가: let written = (|| {
1204추가: staged.last_mut().ok_or(ErrorCode::Internal)?.object = Some(object(&file)?);
1205추가: completed(
1206추가: crate::space::ensure(&file, *length),
1207추가: &mut PublicationMonitor(check),
1208추가: )?;
1209추가: let mut remaining = *length;
1210추가: while remaining != 0 {
1211추가: check(PublishStep::Check)?;
1212추가: let count = remaining.min(buffer.len() as u64) as usize;
1213추가: let n = data.read(&mut buffer[..count]).map_err(|_| ErrorCode::Io)?;
1214추가: if n == 0 {
1215추가: return Err(ErrorCode::Io);
1216추가: }
1217추가: completed(
1218추가: crate::space::ensure(&file, n as u64),
1219추가: &mut PublicationMonitor(check),
1220추가: )?;
1221추가: completed(
1222추가: file.write_all(&buffer[..n]).map_err(crate::space::io_error),
1223추가: &mut PublicationMonitor(check),
1224추가: )?;
1225추가: remaining -= n as u64;
1226추가: }
1227추가: completed(
1228추가: file.sync_all().map_err(crate::space::io_error),
1229추가: &mut PublicationMonitor(check),
1230추가: )
1231추가: })();
1232추가: let closed = completed(
1233추가: close(file).map_err(crate::space::io_error),
1234추가: &mut PublicationMonitor(check),
1235추가: );
1236추가: written.and(closed)?;
1237추가: }
1238추가: let mut owned = staged
1239추가: .iter()
1240추가: .map(|s| Ok((s.temp.clone(), s.object.clone().ok_or(ErrorCode::Internal)?)))
1241추가: .collect::<Result<Vec<_>>>()?;
1242추가: let (name, first) = owned.remove(0);
1243추가: check(PublishStep::Commit(Some(PublicationTemp {
1244추가: parent,
1245추가: name,
1246추가: object: first,
1247추가: others: owned,
1248추가: })))?;
1249추가: // 생성한 임시 파일과 이름이 가리키는 파일이 같은지 모두 확인함.
1250추가: for s in &staged {
1251추가: if root.existing(&s.temp)?.as_ref().map(|file| &file.object) != s.object.as_ref() {
1252추가: return Err(ErrorCode::Conflict);
1253추가: }
1254추가: }
1255추가: for ((name, _), s) in files.iter().zip(&staged) {
1256추가: match root.link(&s.temp, name) {
1257추가: Ok(()) => linked += 1,
1258추가: Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {
1259추가: return Err(ErrorCode::Conflict);
1260추가: }
1261추가: Err(error) => {
1262추가: // 실패한 이름도 되돌리기 대상으로 보고 아래에서 소유 여부를 확인함.
1263추가: linked += 1;
1264추가: return Err(crate::space::io_error(error));
1265추가: }
1266추가: }
1267추가: }
1268추가: Ok(())
1269추가: })();
1270추가: if finish.is_err() {
1271추가: // 게시한 볼륨 중 이 작업이 만든 것만 지움. 다른 파일은 보존함.
1272추가: for ((name, _), s) in files.iter().zip(&staged).take(linked) {
1273추가: match root.existing(name) {
1274추가: Ok(Some(current)) if Some(&current.object) == s.object.as_ref() => {
1275추가: if !root.remove(name) {
1276추가: result.created.push(name.clone());
1277추가: }
1278추가: }
1279추가: Ok(_) => {}
1280추가: Err(_) => result.uncertain = true,
1281추가: }
1282추가: }
1283추가: } else {
1284추가: result.created = files.iter().map(|(name, _)| name.clone()).collect();
1285추가: publication_activity(&mut finish, check);
1286추가: }
1287추가: for s in &staged {
1288추가: match root.existing(&s.temp) {
1289추가: Ok(None) => result.cleanup = Cleanup::Unconfirmed,
1290추가: Ok(Some(current)) if s.object.as_ref() == Some(&current.object) => {
1291추가: if root.remove(&s.temp) {
1292추가: publication_activity(&mut finish, check);
1293추가: } else {
1294추가: result.cleanup = Cleanup::Failed;
1295추가: result.retained.push(s.temp.clone());
1296추가: }
1297추가: }
1298추가: // 이름만 만들고 객체를 확인하지 못한 임시 파일이나 다른 파일은 보존함.
1299추가: _ => {
1300추가: if s.object.is_none() && root.remove(&s.temp) {
1301추가: continue;
1302추가: }
1303추가: result.cleanup = Cleanup::Unconfirmed;
1304추가: }
1305추가: }
1306추가: }
1307추가: if result.cleanup != Cleanup::Complete && finish.is_ok() {
1308추가: finish = Err(ErrorCode::Io);
1309추가: }
1310추가: if !result.created.is_empty() || linked != 0 {
1311추가: match root.sync_checked() {
1312추가: Ok(durability) => {
1313추가: result.durability = durability;
1314추가: publication_activity(&mut finish, check);
1315추가: }
1316추가: Err(error) => {
1317추가: result.durability = Durability::Failed;
1318추가: if finish.is_ok() {
1319추가: finish = Err(error);
1320추가: }
1321추가: }
1322추가: }
1323추가: }
1324추가: if finish.is_ok() {
1325추가: // 이름 기반 게시 뒤에도 결과가 생성한 파일인지 확인함.
1326추가: for ((name, _), s) in files.iter().zip(&staged) {
1327추가: let verified = match root.existing(name) {
1328추가: Ok(Some(current)) if s.object.as_ref() == Some(&current.object) => Ok(()),
1329추가: Ok(_) => Err(ErrorCode::Conflict),
1330추가: Err(error) => Err(error),
1331추가: };
1332추가: if let Err(error) = verified {
1333추가: result.created.retain(|created| created != name);
1334추가: result.uncertain = true;
1335추가: result.durability = Durability::Unconfirmed;
1336추가: if finish.is_ok() {
1337추가: finish = Err(error);
1338추가: }
1339추가: }
1340추가: }
1341추가: }
1342추가: result.error = finish.err();
1343추가: result
1344추가: }
수정experiments/rust-archive-worker/src/protocol.rs+6-0
@@ -6,6 +6,10 @@ pub const MAX_PREVIEW_RGBA_BYTES: u64 = 64 * 1024 * 1024;
66pub const MAX_PREVIEW_DIMENSION: u32 = 8192;
77pub const MAX_PREVIEW_PIXELS: u64 = 16_000_000;
88pub const MAX_PREVIEW_CHUNK_BYTES: usize = 32 * 1024;
9추가: /// 7z 분할 볼륨 하나의 최소 크기 (1 MiB).
10추가: pub const MIN_SEVEN_ZIP_VOLUME_BYTES: u64 = 1024 * 1024;
11추가: /// 분할 7z 읽기가 받는 최대 볼륨 수 (`이름.7z.001`~`이름.7z.999`).
12추가: pub const MAX_SEVEN_ZIP_VOLUMES: u64 = 999;
913
1014#[derive(Clone, Debug, PartialEq, Eq)]
1115pub enum NativePath {
@@ -247,6 +251,8 @@ pub enum Action {
247251 method: SevenZipMethod,
248252 solid: bool,
249253 encryption: Encryption,
254추가: /// 있으면 `output_file`(이름.7z) 대신 이 크기로 나눈 `이름.7z.001`, `이름.7z.002`, …를 만듦.
255추가: volume_size: Option<u64>,
250256 },
251257}
252258#[derive(Clone, Copy, Debug, PartialEq, Eq)]
수정experiments/rust-archive-worker/src/runtime.rs+141-13
@@ -439,6 +439,72 @@ impl<W: Write> Job<W> {
439439 }
440440 Ok(())
441441 }
442추가: /// 분할 7z 볼륨을 한 묶음으로 게시함. 실패하면 게시한 볼륨을 되돌림.
443추가: fn output_set(
444추가: &mut self,
445추가: root: &Dir,
446추가: files: &[(String, u64)],
447추가: data: &mut impl Read,
448추가: ) -> Result<()> {
449추가: self.check()?;
450추가: let total = files
451추가: .iter()
452추가: .try_fold(0u64, |sum, (_, length)| sum.checked_add(*length))
453추가: .ok_or(ErrorCode::Limit)?;
454추가: self.progress(
455추가: Stage::Write,
456추가: 0,
457추가: Some(total),
458추가: self.terminal.created_count as u32,
459추가: )?;
460추가: let p = filesystem::publish_set_steps(root, files, data, &mut |step| {
461추가: self.publication_step(step, true)
462추가: });
463추가: self.terminal.retained_partial_count += p.retained.len() as u64;
464추가: if p.cleanup != Cleanup::Complete {
465추가: self.terminal.cleanup = p.cleanup;
466추가: }
467추가: if !p.created.is_empty() {
468추가: self.terminal.publication = Publication::Partial;
469추가: self.terminal.durability = match (self.terminal.durability, p.durability) {
470추가: (Durability::Failed, _) | (_, Durability::Failed) => Durability::Failed,
471추가: (Durability::Unconfirmed, _) | (_, Durability::Unconfirmed) => {
472추가: Durability::Unconfirmed
473추가: }
474추가: _ => p.durability,
475추가: };
476추가: }
477추가: for name in &p.created {
478추가: self.terminal.created_count += 1;
479추가: self.event(Message::Output {
480추가: entry_id: None,
481추가: relative_name: name.clone(),
482추가: disposition: Disposition::Created,
483추가: })?;
484추가: }
485추가: if p.uncertain {
486추가: self.terminal.publication = Publication::Uncertain;
487추가: self.terminal.durability = Durability::Unconfirmed;
488추가: for (name, _) in files.iter().filter(|(name, _)| !p.created.contains(name)) {
489추가: self.event(Message::Output {
490추가: entry_id: None,
491추가: relative_name: name.clone(),
492추가: disposition: Disposition::CommitUncertain,
493추가: })?;
494추가: }
495추가: }
496추가: for name in &p.retained {
497추가: self.event(Message::Output {
498추가: entry_id: None,
499추가: relative_name: name.clone(),
500추가: disposition: Disposition::PartialRetained,
501추가: })?;
502추가: }
503추가: if let Some(error) = p.error {
504추가: return Err(error);
505추가: }
506추가: completed(Ok(()), self)
507추가: }
442508 fn direct_snapshot(
443509 &mut self,
444510 path: &std::path::Path,
@@ -1125,6 +1191,7 @@ impl<W: Write> Job<W> {
11251191 Action::CreateSevenZip {
11261192 sources,
11271193 output_file,
1194추가: volume_size,
11281195 ..
11291196 } => {
11301197 let output = output_file.to_path()?;
@@ -1133,22 +1200,53 @@ impl<W: Write> Job<W> {
11331200 .and_then(|n| n.to_str())
11341201 .ok_or(ErrorCode::InvalidRequest)?;
11351202 let name = archive::valid_name(leaf, false)?;
1136삭제: let root = completed(
1137삭제: Dir::root(output.parent().ok_or(ErrorCode::InvalidRequest)?),
1138삭제: self,
1139삭제: )?;
1140삭제: filesystem::preflight_mode_with(
1141삭제: &root,
1142삭제: &[(name.clone(), EntryKind::File)],
1143삭제: false,
1144삭제: self,
1145삭제: )?;
1203추가: let parent = output.parent().ok_or(ErrorCode::InvalidRequest)?;
1204추가: let root = completed(Dir::root(parent), self)?;
1205추가: if let Some(size) = volume_size {
1206추가: // 분할 읽기가 찾는 `이름.7z.001` 형식만 만들고 너무 작은 볼륨은 거부함.
1207추가: if size < MIN_SEVEN_ZIP_VOLUME_BYTES
1208추가: || !name.to_ascii_lowercase().ends_with(".7z")
1209추가: {
1210추가: return Err(ErrorCode::InvalidRequest);
1211추가: }
1212추가: filesystem::preflight_mode_with(
1213추가: &root,
1214추가: &[(
1215추가: crate::seven_zip_create::volume_name(&name, 1)?,
1216추가: EntryKind::File,
1217추가: )],
1218추가: false,
1219추가: self,
1220추가: )?;
1221추가: self.split_names_free(parent, &name)?;
1222추가: } else {
1223추가: filesystem::preflight_mode_with(
1224추가: &root,
1225추가: &[(name.clone(), EntryKind::File)],
1226추가: false,
1227추가: self,
1228추가: )?;
1229추가: }
11461230 self.progress(Stage::Scan, 0, None, 0)?;
11471231 let mut plan = crate::create::plan(&sources, limits, self)?;
11481232 let (mut data, length) = crate::seven_zip_create::archive(&mut plan, limits, self)?;
1149삭제: filesystem::preflight_space_with(&root, &[(name.clone(), length)], None, self)?;
1150삭제: self.creation_plan = Some(plan);
1151삭제: self.output_reader(&root, &name, &mut data, length, None, true, None)?;
1233추가: if let Some(size) = volume_size {
1234추가: let files = crate::seven_zip_create::volumes(&name, length, size)?;
1235추가: let kinds = files
1236추가: .iter()
1237추가: .map(|(file, _)| (file.clone(), EntryKind::File))
1238추가: .collect::<Vec<_>>();
1239추가: // 모든 볼륨 이름이 비어 있는지 다시 확인함. 압축하는 사이 생긴 이름도 거부함.
1240추가: filesystem::preflight_mode_with(&root, &kinds, false, self)?;
1241추가: self.split_names_free(parent, &name)?;
1242추가: filesystem::preflight_space_with(&root, &files, None, self)?;
1243추가: self.creation_plan = Some(plan);
1244추가: self.output_set(&root, &files, &mut data)?;
1245추가: } else {
1246추가: filesystem::preflight_space_with(&root, &[(name.clone(), length)], None, self)?;
1247추가: self.creation_plan = Some(plan);
1248추가: self.output_reader(&root, &name, &mut data, length, None, true, None)?;
1249추가: }
11521250 self.terminal.publication = Publication::Complete;
11531251 }
11541252 }
@@ -1156,6 +1254,36 @@ impl<W: Write> Job<W> {
11561254 Ok(())
11571255 }
11581256}
1257추가: impl<W: Write> Job<W> {
1258추가: /// 분할 읽기는 같은 폴더의 `이름.7z.<숫자>`를 모두 한 묶음으로 보므로,
1259추가: /// 자릿수와 관계없이 그런 이름이 하나라도 있으면 새 볼륨을 만들지 않음.
1260추가: fn split_names_free(&mut self, parent: &std::path::Path, name: &str) -> Result<()> {
1261추가: let fold = |value: &str| {
1262추가: if cfg!(windows) {
1263추가: value.to_lowercase()
1264추가: } else {
1265추가: value.to_owned()
1266추가: }
1267추가: };
1268추가: let prefix = fold(&format!("{name}."));
1269추가: let entries = completed(
1270추가: std::fs::read_dir(parent).map_err(crate::space::io_error),
1271추가: self,
1272추가: )?;
1273추가: for entry in entries {
1274추가: self.check()?;
1275추가: let leaf = entry.map_err(crate::space::io_error)?.file_name();
1276추가: let leaf = fold(&leaf.to_string_lossy());
1277추가: if let Some(suffix) = leaf.strip_prefix(&prefix) {
1278추가: if !suffix.is_empty() && suffix.bytes().all(|b| b.is_ascii_digit()) {
1279추가: return Err(ErrorCode::Conflict);
1280추가: }
1281추가: }
1282추가: completed(Ok(()), self)?;
1283추가: }
1284추가: Ok(())
1285추가: }
1286추가: }
11591287impl<W: Write> Monitor for Job<W> {
11601288 fn progress(
11611289 &mut self,
수정experiments/rust-archive-worker/src/seven_zip_create.rs+30-0
@@ -448,6 +448,36 @@ pub(crate) fn archive(
448448 Ok((output, length))
449449}
450450
451추가: /// 분할 7z 볼륨 이름 (`이름.7z.001` 형식).
452추가: pub(crate) fn volume_name(name: &str, index: u64) -> Result<String> {
453추가: if !(1..=MAX_SEVEN_ZIP_VOLUMES).contains(&index) {
454추가: return Err(ErrorCode::Limit);
455추가: }
456추가: crate::archive::valid_name(&format!("{name}.{index:03}"), false)
457추가: }
458추가: /// 완성한 7z 길이를 볼륨 크기로 나눈 (이름, 길이) 목록. 마지막 볼륨만 짧을 수 있음.
459추가: /// 분할 읽기가 받는 999개를 넘거나 볼륨이 최소 크기보다 작으면 거부함.
460추가: pub(crate) fn volumes(name: &str, length: u64, size: u64) -> Result<Vec<(String, u64)>> {
461추가: if size < MIN_SEVEN_ZIP_VOLUME_BYTES || length == 0 {
462추가: return Err(ErrorCode::InvalidRequest);
463추가: }
464추가: let count = length.div_ceil(size);
465추가: if count > MAX_SEVEN_ZIP_VOLUMES {
466추가: return Err(ErrorCode::Limit);
467추가: }
468추가: let mut files = Vec::new();
469추가: files
470추가: .try_reserve_exact(count as usize)
471추가: .map_err(|_| ErrorCode::Limit)?;
472추가: for index in 0..count {
473추가: files.push((
474추가: volume_name(name, index + 1)?,
475추가: size.min(length - index * size),
476추가: ));
477추가: }
478추가: Ok(files)
479추가: }
480추가:
451481#[cfg(test)]
452482#[path = "../../../tests/rust-archive-worker/seven_zip_create_fields.rs"]
453483mod tests;
수정experiments/rust-archive-worker/src/wire.rs+4-1
@@ -469,13 +469,15 @@ impl Wire for Action {
469469 method,
470470 solid,
471471 encryption,
472추가: volume_size,
472473 } => {
473474 4u8.enc(e)?;
474475 sources.enc(e)?;
475476 output_file.enc(e)?;
476477 method.enc(e)?;
477478 solid.enc(e)?;
478삭제: encryption.enc(e)
479추가: encryption.enc(e)?;
480추가: volume_size.enc(e)
479481 }
480482 }
481483 }
@@ -512,6 +514,7 @@ impl Wire for Action {
512514 method: Wire::dec(d)?,
513515 solid: Wire::dec(d)?,
514516 encryption: Wire::dec(d)?,
517추가: volume_size: Wire::dec(d)?,
515518 }),
516519 _ => Err(invalid()),
517520 }
수정experiments/rust-ui-memory-app/src/archive_present.rs+67-1
@@ -469,7 +469,73 @@ pub fn volume_problem_text(problem: &VolumeProblem) -> String {
469469}
470470
471471pub const SPLIT_SUPPORT: &str =
472삭제: "분할 7z는 .7z.001부터 열 수 있습니다. 분할 ZIP과 RAR, 분할 압축 만들기는 지원하지 않습니다.";
472추가: "분할 7z는 .7z.001부터 열 수 있습니다. 분할 ZIP과 RAR는 지원하지 않습니다.";
473추가:
474추가: /// 7z 분할 볼륨 크기 단위. 크기 표시(bytes_text)와 같이 1 MB = 1,048,576바이트.
475추가: #[derive(Clone, Copy, Debug, PartialEq, Eq)]
476추가: pub enum VolumeUnit {
477추가: Mb,
478추가: Gb,
479추가: }
480추가: impl VolumeUnit {
481추가: pub fn label(self) -> &'static str {
482추가: match self {
483추가: Self::Mb => "MB",
484추가: Self::Gb => "GB",
485추가: }
486추가: }
487추가: fn bytes(self) -> u64 {
488추가: match self {
489추가: Self::Mb => 1 << 20,
490추가: Self::Gb => 1 << 30,
491추가: }
492추가: }
493추가: }
494추가: /// 분할 7z 볼륨 수 상한. 분할 읽기는 `.001`부터 `.999`까지만 찾음.
495추가: pub const MAX_VOLUMES: u64 = worker_protocol::protocol::MAX_SEVEN_ZIP_VOLUMES;
496추가: pub const VOLUME_SIZE_ERROR: &str = "쪼갤 용량은 1 이상의 정수로 입력하세요";
497추가: pub const VOLUME_LIMIT_ERROR: &str =
498추가: "볼륨이 999개를 넘거나 처리 한도를 넘었습니다. 쪼갤 용량을 늘려 다시 만드세요";
499추가:
500추가: /// 입력한 숫자와 단위를 볼륨 바이트 수로 바꿈. 최소 1 MB이고 정수만 받음.
501추가: pub fn volume_size(amount: &str, unit: VolumeUnit) -> Result<u64, &'static str> {
502추가: let amount = amount.trim();
503추가: if amount.is_empty() || amount.len() > 9 || !amount.bytes().all(|b| b.is_ascii_digit()) {
504추가: return Err(VOLUME_SIZE_ERROR);
505추가: }
506추가: amount
507추가: .parse::<u64>()
508추가: .ok()
509추가: .and_then(|value| value.checked_mul(unit.bytes()))
510추가: .filter(|bytes| *bytes >= worker_protocol::protocol::MIN_SEVEN_ZIP_VOLUME_BYTES)
511추가: .ok_or(VOLUME_SIZE_ERROR)
512추가: }
513추가:
514추가: /// 분할 7z의 `index`번째 볼륨 경로 (`이름.7z.001` 형식).
515추가: pub fn volume_path(output: &Path, index: u64) -> PathBuf {
516추가: let mut name = output.as_os_str().to_owned();
517추가: name.push(format!(".{index:03}"));
518추가: PathBuf::from(name)
519추가: }
520추가:
521추가: /// 같은 폴더에 분할 읽기가 한 묶음으로 볼 `이름.7z.<숫자>`가 이미 있으면 그 이름.
522추가: pub fn existing_volume(output: &Path) -> Option<String> {
523추가: let parent = output.parent()?;
524추가: let prefix = format!("{}.", output.file_name()?.to_str()?);
525추가: let fold = |value: &str| {
526추가: if cfg!(windows) {
527추가: value.to_lowercase()
528추가: } else {
529추가: value.to_owned()
530추가: }
531추가: };
532추가: let prefix = fold(&prefix);
533추가: fs::read_dir(parent).ok()?.flatten().find_map(|entry| {
534추가: let name = entry.file_name().to_string_lossy().into_owned();
535추가: let suffix = fold(&name).strip_prefix(&prefix)?.to_owned();
536추가: (!suffix.is_empty() && suffix.bytes().all(|b| b.is_ascii_digit())).then_some(name)
537추가: })
538추가: }
473539
474540pub fn excluded_split(path: &Path) -> bool {
475541 let name = path
수정experiments/rust-ui-memory-app/src/archive_process.rs+2-0
@@ -213,6 +213,7 @@ fn start_to_wire(start: ui::Start) -> wire::Start {
213213 ui::Start::CreateSevenZip {
214214 sources,
215215 output_file,
216추가: volume_size,
216217 } => wire::Action::CreateSevenZip {
217218 sources: sources
218219 .into_iter()
@@ -227,6 +228,7 @@ fn start_to_wire(start: ui::Start) -> wire::Start {
227228 method: wire::SevenZipMethod::Lzma2,
228229 solid: false,
229230 encryption: wire::Encryption::None,
231추가: volume_size,
230232 },
231233 ui::Start::CreateZip {
232234 sources,
수정experiments/rust-ui-memory-app/src/archive_screen.rs+144-5
@@ -261,6 +261,10 @@ pub struct ArchiveApp {
261261 selected_only: bool,
262262 method: Method,
263263 seven_zip: bool,
264추가: /// 7z 만들기에서 "쪼갤 용량 설정"을 켰는지와 입력한 볼륨 크기.
265추가: split: bool,
266추가: split_amount: String,
267추가: split_unit: present::VolumeUnit,
264268 dialogs: Box<dyn Dialogs>,
265269 picker: Option<(Purpose, std::sync::mpsc::Receiver<DialogAnswer>)>,
266270 preview_open: bool,
@@ -348,6 +352,9 @@ impl ArchiveApp {
348352 selected_only: false,
349353 method: Method::Deflate,
350354 seven_zip: false,
355추가: split: false,
356추가: split_amount: "100".into(),
357추가: split_unit: present::VolumeUnit::Mb,
351358 dialogs: Box::new(NativeDialogs),
352359 picker: None,
353360 preview_open: false,
@@ -720,6 +727,14 @@ impl ArchiveApp {
720727 && self.zip_password == self.zip_password_confirm)
721728 }
722729
730추가: /// 7z 분할을 켰으면 볼륨 바이트 수. 입력이 잘못됐으면 화면에 보일 오류.
731추가: fn split_volume(&self) -> Result<Option<u64>, &'static str> {
732추가: if !self.seven_zip || !self.split {
733추가: return Ok(None);
734추가: }
735추가: present::volume_size(&self.split_amount, self.split_unit).map(Some)
736추가: }
737추가:
723738 fn close_create(&mut self) {
724739 self.create = false;
725740 self.ui_error = None;
@@ -955,8 +970,23 @@ impl ArchiveApp {
955970 self.ui_error = Some("압축파일 이름을 확인하세요".into());
956971 return;
957972 }
973추가: let volume_size = match self.split_volume() {
974추가: Ok(size) => size,
975추가: Err(error) => {
976추가: self.ui_error = Some(error.into());
977추가: return;
978추가: }
979추가: };
958980 let output_file = self.zip_folder.join(&self.zip_name);
959삭제: if std::fs::symlink_metadata(&output_file).is_ok() {
981추가: if volume_size.is_some() {
982추가: // 분할 읽기는 같은 이름의 숫자 조각을 모두 한 묶음으로 보므로 하나라도 있으면 막음.
983추가: if let Some(existing) = present::existing_volume(&output_file) {
984추가: self.ui_error = Some(format!(
985추가: "같은 이름의 분할 파일({existing})이 이미 있습니다. 다른 이름을 입력하세요"
986추가: ));
987추가: return;
988추가: }
989추가: } else if std::fs::symlink_metadata(&output_file).is_ok() {
960990 self.ui_error = Some("같은 이름의 파일이 이미 있습니다. 다른 이름을 입력하세요".into());
961991 return;
962992 }
@@ -984,7 +1014,16 @@ impl ArchiveApp {
9841014 self.ui_error = Some("두 암호가 같은지 확인하세요".into());
9851015 return;
9861016 }
987삭제: self.targets = Some([self.zip_name.clone()].into_iter().collect());
1017추가: // 분할하면 볼륨 수를 미리 알 수 없으므로 결과 화면에서 보고된 수로 이름을 다시 정함.
1018추가: self.targets = Some(
1019추가: [if volume_size.is_some() {
1020추가: format!("{}.001", self.zip_name)
1021추가: } else {
1022추가: self.zip_name.clone()
1023추가: }]
1024추가: .into_iter()
1025추가: .collect(),
1026추가: );
9881027 self.directories.clear();
9891028 // 암호는 ZIP 만들기 창에서 받아 두었다가 작업자가 요청하면 넘김.
9901029 let password = self.aes256.then(|| std::mem::take(&mut self.zip_password));
@@ -992,6 +1031,7 @@ impl ArchiveApp {
9921031 Start::CreateSevenZip {
9931032 sources,
9941033 output_file,
1034추가: volume_size,
9951035 }
9961036 } else {
9971037 Start::CreateZip {
@@ -1193,9 +1233,19 @@ impl ArchiveApp {
11931233 }
11941234 self.extract_selection(selection);
11951235 }
1196삭제: Start::CreateSevenZip { .. } => {
1236추가: Start::CreateSevenZip { volume_size, .. } => {
11971237 self.set_seven_zip(true);
11981238 self.create = true;
1239추가: self.split = volume_size.is_some();
1240추가: if let Some(size) = volume_size {
1241추가: let (amount, unit) = if size % (1 << 30) == 0 {
1242추가: (size >> 30, present::VolumeUnit::Gb)
1243추가: } else {
1244추가: (size >> 20, present::VolumeUnit::Mb)
1245추가: };
1246추가: self.split_amount = amount.to_string();
1247추가: self.split_unit = unit;
1248추가: }
11991249 self.begin_zip();
12001250 }
12011251 Start::CreateZip { aes256, .. } => {
@@ -3169,8 +3219,24 @@ impl ArchiveApp {
31693219 self.last_request,
31703220 Some(Start::CreateZip { .. } | Start::CreateSevenZip { .. })
31713221 );
3222추가: // 분할 7z는 작업자가 보고한 볼륨 수로 기대 이름(이름.7z.001…)을 정함.
3223추가: let split_targets = match (&self.last_request, t.as_ref()) {
3224추가: (
3225추가: Some(Start::CreateSevenZip {
3226추가: output_file,
3227추가: volume_size: Some(_),
3228추가: ..
3229추가: }),
3230추가: Some(t),
3231추가: ) => output_file.file_name().map(|name| {
3232추가: (1..=t.created_count.clamp(1, present::MAX_VOLUMES))
3233추가: .map(|index| format!("{}.{index:03}", name.to_string_lossy()))
3234추가: .collect::<BTreeSet<_>>()
3235추가: }),
3236추가: _ => None,
3237추가: };
31723238 let resolved_targets = present::resolved_targets(
3173삭제: self.targets.as_ref(),
3239추가: split_targets.as_ref().or(self.targets.as_ref()),
31743240 &self.model.entries,
31753241 matches!(
31763242 self.last_request,
@@ -3280,6 +3346,11 @@ impl ArchiveApp {
32803346 .show(ui, |ui| {
32813347 if success && t.as_ref().is_some_and(|t| t.created_count > 0) {
32823348 let path = match self.last_request.as_ref() {
3349추가: Some(Start::CreateSevenZip {
3350추가: output_file,
3351추가: volume_size: Some(_),
3352추가: ..
3353추가: }) => present::volume_path(output_file, 1).display().to_string(),
32833354 Some(
32843355 Start::CreateZip { output_file, .. }
32853356 | Start::CreateSevenZip { output_file, .. },
@@ -3287,6 +3358,18 @@ impl ArchiveApp {
32873358 _ => format!("{} 폴더에 저장했습니다.", self.destination.display()),
32883359 };
32893360 theme::bounded_text(ui, &path, ui.available_width());
3361추가: if matches!(
3362추가: self.last_request,
3363추가: Some(Start::CreateSevenZip {
3364추가: volume_size: Some(_),
3365추가: ..
3366추가: })
3367추가: ) {
3368추가: ui.label(format!(
3369추가: "볼륨 {}개로 나누어 저장했습니다. 풀 때는 첫 볼륨(.001)을 여세요.",
3370추가: t.as_ref().map_or(0, |t| t.created_count)
3371추가: ));
3372추가: }
32903373 } else if let Some(problem) = &self.model.volume_problem {
32913374 ui.add(egui::Label::new(present::volume_problem_text(problem)).wrap());
32923375 } else if let Some(code) = t.as_ref().and_then(|t| t.error) {
@@ -3304,6 +3387,16 @@ impl ArchiveApp {
33043387 } else if creating && code == ErrorCode::SourceChanged {
33053388 "묶을 파일이 바뀌었습니다. 파일을 확인한 뒤 다시 만드세요"
33063389 .to_owned()
3390추가: } else if code == ErrorCode::Limit
3391추가: && matches!(
3392추가: self.last_request,
3393추가: Some(Start::CreateSevenZip {
3394추가: volume_size: Some(_),
3395추가: ..
3396추가: })
3397추가: )
3398추가: {
3399추가: present::VOLUME_LIMIT_ERROR.to_owned()
33073400 } else {
33083401 present::operation_text(present::error_text(code), creating)
33093402 },
@@ -3870,6 +3963,7 @@ impl ArchiveApp {
38703963 // 암호: 체크하면 바로 아래에 암호와 암호 확인 칸을 보여 줌.
38713964 if self.seven_zip {
38723965 ui.label("7z는 암호를 지원하지 않습니다. 암호가 필요하면 ZIP을 선택하세요");
3966추가: self.split_rows(ui);
38733967 return false;
38743968 }
38753969 let check = ui.checkbox(&mut self.aes256, "암호로 보호하기");
@@ -3935,9 +4029,54 @@ impl ArchiveApp {
39354029 false
39364030 }
39374031
4032추가: /// 쪼갤 용량: 체크하면 바로 아래에 볼륨 크기 칸과 MB/GB 선택을 보여 줌.
4033추가: fn split_rows(&mut self, ui: &mut egui::Ui) {
4034추가: let check = ui.checkbox(&mut self.split, "쪼갤 용량 설정");
4035추가: theme::pointer(&check);
4036추가: theme::focus(&check);
4037추가: if !self.split {
4038추가: return;
4039추가: }
4040추가: ui.horizontal(|ui| {
4041추가: ui.add_sized([72.0, theme::FIELD], egui::Label::new("볼륨 크기"));
4042추가: let edit = ui.add_sized(
4043추가: [120.0, theme::FIELD],
4044추가: egui::TextEdit::singleline(&mut self.split_amount)
4045추가: .id(egui::Id::unique("split-volume-size"))
4046추가: .char_limit(9)
4047추가: .align(egui::Align2::LEFT_CENTER),
4048추가: );
4049추가: theme::focus(&edit);
4050추가: for unit in [present::VolumeUnit::Mb, present::VolumeUnit::Gb] {
4051추가: let choice = ui.selectable_value(&mut self.split_unit, unit, unit.label());
4052추가: theme::pointer(&choice);
4053추가: }
4054추가: });
4055추가: match self.split_volume() {
4056추가: Err(error) => {
4057추가: ui.colored_label(theme::ERROR, error);
4058추가: }
4059추가: Ok(_) => {
4060추가: let name = if self.zip_name.is_empty() {
4061추가: "이름.7z"
4062추가: } else {
4063추가: &self.zip_name
4064추가: };
4065추가: ui.label(
4066추가: RichText::new(format!(
4067추가: "{name}.001, {name}.002 …로 나누어 저장합니다. 볼륨은 최대 {}개입니다.",
4068추가: present::MAX_VOLUMES
4069추가: ))
4070추가: .color(theme::MUTED),
4071추가: );
4072추가: }
4073추가: }
4074추가: }
4075추가:
39384076 /// 취소와 압축하기 버튼. 취소를 눌렀으면 true.
39394077 fn create_actions(&mut self, ui: &mut egui::Ui) -> bool {
3940삭제: let ready = !self.sources.is_empty() && self.zip_password_ready();
4078추가: let ready =
4079추가: !self.sources.is_empty() && self.zip_password_ready() && self.split_volume().is_ok();
39414080 let enabled = self.picker.is_none();
39424081 let (cancel, compress) = ui
39434082 .add_enabled_ui(enabled, |ui| {
수정experiments/rust-ui-memory-app/src/archive_ui.rs+16-0
@@ -76,6 +76,8 @@ pub enum Start {
7676 CreateSevenZip {
7777 sources: Vec<(PathBuf, String)>,
7878 output_file: PathBuf,
79추가: /// 있으면 `output_file`(이름.7z) 대신 이 크기의 `이름.7z.001`, `이름.7z.002`, …로 나눔.
80추가: volume_size: Option<u64>,
7981 },
8082 CreateZip {
8183 sources: Vec<(PathBuf, String)>,
@@ -673,6 +675,7 @@ impl Model {
673675 | Start::CreateSevenZip {
674676 sources,
675677 output_file,
678추가: ..
676679 } => {
677680 !sources.is_empty()
678681 && output_file.is_absolute()
@@ -680,6 +683,19 @@ impl Model {
680683 .iter()
681684 .all(|(p, n)| p.is_absolute() && valid_relative(n))
682685 }
686추가: } && match &start {
687추가: // 분할은 `이름.7z`에 볼륨 번호를 붙이므로 .7z 이름과 최소 볼륨 크기를 요구함.
688추가: Start::CreateSevenZip {
689추가: output_file,
690추가: volume_size: Some(size),
691추가: ..
692추가: } => {
693추가: *size >= worker_protocol::protocol::MIN_SEVEN_ZIP_VOLUME_BYTES
694추가: && output_file
695추가: .extension()
696추가: .is_some_and(|ext| ext.eq_ignore_ascii_case("7z"))
697추가: }
698추가: _ => true,
683699 };
684700 if !validation {
685701 self.input_error = Some("입력 경로, 출력명과 선택한 목록을 확인하세요".into());
수정tests/rust-app-ui/conflict_codec.rs+15-0
@@ -115,6 +115,7 @@ fn sevenzip_creation_adapter_preserves_paths_and_fixed_options() {
115115 let converted = start_to_wire(ui::Start::CreateSevenZip {
116116 sources: vec![(source.clone(), "원본".into())],
117117 output_file: output.clone(),
118추가: volume_size: None,
118119 });
119120 match converted.action {
120121 wire::Action::CreateSevenZip {
@@ -123,7 +124,9 @@ fn sevenzip_creation_adapter_preserves_paths_and_fixed_options() {
123124 method,
124125 solid,
125126 encryption,
127추가: volume_size,
126128 } => {
129추가: assert_eq!(volume_size, None);
127130 assert_eq!(sources[0].archive_name, "원본");
128131 assert_eq!(
129132 sources[0].path,
@@ -139,4 +142,16 @@ fn sevenzip_creation_adapter_preserves_paths_and_fixed_options() {
139142 }
140143 other => panic!("잘못된 생성 형식: {other:?}"),
141144 }
145추가: let converted = start_to_wire(ui::Start::CreateSevenZip {
146추가: sources: vec![(source, "원본".into())],
147추가: output_file: output,
148추가: volume_size: Some(700 * 1024 * 1024),
149추가: });
150추가: assert!(matches!(
151추가: converted.action,
152추가: wire::Action::CreateSevenZip {
153추가: volume_size: Some(size),
154추가: ..
155추가: } if size == 700 * 1024 * 1024
156추가: ));
142157}
수정tests/rust-app-ui/create_window.rs+75-1
@@ -662,7 +662,7 @@ fn sevenzip_selection_clears_zip_password_and_sends_only_supported_options() {
662662 assert_eq!(save.purpose, Purpose::SaveSevenZip);
663663 assert_eq!(save.file_name, "photos.7z");
664664 assert!(matches!(factory.state.borrow().starts.last(),
665삭제: Some(Start::CreateSevenZip { sources, output_file })
665추가: Some(Start::CreateSevenZip { sources, output_file, volume_size: None })
666666 if sources.len() == 1 && sources[0].1 == "photos" && output_file.ends_with("photos.7z")));
667667 assert!(!factory.state.borrow().password_seen);
668668}
@@ -682,3 +682,77 @@ fn cancelling_sevenzip_save_keeps_selected_format_without_starting() {
682682 assert!(shown.iter().any(|(s, _)| s == "7z 만들기"));
683683 assert!(shown.iter().any(|(s, _)| s == "LZMA2"));
684684}
685추가:
686추가: #[test]
687추가: fn sevenzip_split_checkbox_validates_volume_size_and_sends_it() {
688추가: let scratch = Folder::new();
689추가: let factory = FakeFactory::default();
690추가: let (mut app, ctx) = create_from_folder(&scratch, &factory);
691추가: let shown = |app: &mut ArchiveApp, label: &str| {
692추가: policy_render(&ctx, app, vec![])
693추가: .iter()
694추가: .any(|(text, _)| text == label)
695추가: };
696추가: // ZIP에서는 분할 설정을 보이지 않고, 7z를 고르면 체크만 보임.
697추가: assert!(!shown(&mut app, "쪼갤 용량 설정"));
698추가: policy_click(&ctx, &mut app, "7z");
699추가: assert!(shown(&mut app, "쪼갤 용량 설정"));
700추가: assert!(!shown(&mut app, "볼륨 크기"));
701추가:
702추가: policy_click(&ctx, &mut app, "쪼갤 용량 설정");
703추가: assert!(shown(&mut app, "볼륨 크기"));
704추가: assert!(shown(&mut app, "MB"));
705추가: assert!(shown(&mut app, "GB"));
706추가: assert!(policy_render(&ctx, &mut app, vec![])
707추가: .iter()
708추가: .any(|(text, _)| text.starts_with("photos.7z.001, photos.7z.002")));
709추가:
710추가: // 0, 문자, 소수는 빨간 안내를 보이고 저장 창도 열지 않음.
711추가: let dialogs = TestDialogs::default();
712추가: app.set_dialogs(Box::new(dialogs.clone()));
713추가: for value in ["0", "abc", "1.5", ""] {
714추가: text(&ctx, &mut app, "split-volume-size", value);
715추가: assert!(
716추가: shown(&mut app, "쪼갤 용량은 1 이상의 정수로 입력하세요"),
717추가: "{value}"
718추가: );
719추가: policy_click(&ctx, &mut app, "압축하기");
720추가: assert!(dialogs.0.borrow().requests.is_empty(), "{value}");
721추가: assert_eq!(factory.state.borrow().starts.len(), 1, "{value}");
722추가: }
723추가:
724추가: // 같은 이름의 숫자 조각이 이미 있으면 시작하지 않음.
725추가: text(&ctx, &mut app, "split-volume-size", "2");
726추가: policy_click(&ctx, &mut app, "GB");
727추가: assert!(!shown(&mut app, "쪼갤 용량은 1 이상의 정수로 입력하세요"));
728추가: fs::write(scratch.0.join("photos.7z.003"), b"old").unwrap();
729추가: policy_click(&ctx, &mut app, "압축하기");
730추가: assert_eq!(factory.state.borrow().starts.len(), 1);
731추가: assert!(policy_render(&ctx, &mut app, vec![])
732추가: .iter()
733추가: .any(|(text, _)| text.contains("photos.7z.003")));
734추가: fs::remove_file(scratch.0.join("photos.7z.003")).unwrap();
735추가:
736추가: policy_click(&ctx, &mut app, "압축하기");
737추가: assert!(matches!(factory.state.borrow().starts.last(),
738추가: Some(Start::CreateSevenZip { output_file, volume_size: Some(size), .. })
739추가: if output_file.ends_with("photos.7z") && *size == 2 * 1024 * 1024 * 1024));
740추가:
741추가: // 체크를 해제하면 분할하지 않은 요청을 보냄.
742추가: let (mut app, ctx) = create_from_folder(&scratch, &factory);
743추가: policy_click(&ctx, &mut app, "7z");
744추가: policy_click(&ctx, &mut app, "쪼갤 용량 설정");
745추가: policy_click(&ctx, &mut app, "쪼갤 용량 설정");
746추가: assert!(!policy_render(&ctx, &mut app, vec![])
747추가: .iter()
748추가: .any(|(text, _)| text == "볼륨 크기"));
749추가: app.set_dialogs(Box::new(TestDialogs::default()));
750추가: policy_click(&ctx, &mut app, "압축하기");
751추가: assert!(matches!(
752추가: factory.state.borrow().starts.last(),
753추가: Some(Start::CreateSevenZip {
754추가: volume_size: None,
755추가: ..
756추가: })
757추가: ));
758추가: }
수정tests/rust-app-ui/regressions.rs+2-0
@@ -887,6 +887,7 @@ fn sevenzip_creation_rejects_password_prompts_and_encrypted_acceptance() {
887887 Start::CreateSevenZip {
888888 sources: vec![(path("source"), "source".into())],
889889 output_file: path("output.7z"),
890추가: volume_size: None,
890891 },
891892 &mut f
892893 ));
@@ -917,6 +918,7 @@ fn sevenzip_creation_waits_for_both_eofs_and_child_reap() {
917918 Start::CreateSevenZip {
918919 sources: vec![(path("source"), "source".into())],
919920 output_file: path("output.7z"),
921추가: volume_size: None,
920922 },
921923 &mut f
922924 ));
수정tests/rust-app-ui/scenario_tests.rs+30-0
@@ -186,6 +186,9 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
186186 "create-sevenzip-error" => "7z 파일을 만들지 못했습니다",
187187 "create-sevenzip-cancelled" => "작업을 취소했습니다",
188188 "create-sevenzip-resource" => "큰 작업을 허용할까요?",
189추가: "create-sevenzip-split" => "쪼갤 용량 설정",
190추가: "create-sevenzip-split-invalid" => "쪼갤 용량은 1 이상의 정수로 입력하세요",
191추가: "create-sevenzip-split-complete" => "볼륨 3개로 나누어 저장했습니다",
189192 "create-error" => "ZIP 파일을 만들지 못했습니다",
190193 "password-create" => "암호 확인",
191194 "folder" => "바다.jpg",
@@ -226,6 +229,33 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
226229 };
227230 assert_eq!(paths, expected, "{}", scenario.name);
228231 }
232추가: match scenario.name {
233추가: "create-sevenzip-split" => {
234추가: for label in [
235추가: "볼륨 크기",
236추가: "700",
237추가: "MB",
238추가: "GB",
239추가: "여행 자료.7z.001, 여행 자료.7z.002",
240추가: ] {
241추가: assert!(labels.contains(label), "{label}: {labels}");
242추가: }
243추가: assert!(!labels.contains("쪼갤 용량은"), "{labels}");
244추가: assert_eq!(scenarios::split_volume(&app), Ok(Some(700 * 1024 * 1024)));
245추가: }
246추가: "create-sevenzip-split-invalid" => {
247추가: assert!(scenarios::split_volume(&app).is_err());
248추가: assert!(!labels.contains("여행 자료.7z.001"), "{labels}");
249추가: }
250추가: "create-sevenzip-split-complete" => {
251추가: let terminal = app.model.terminal.as_ref().unwrap();
252추가: assert_eq!(terminal.created_count, 3);
253추가: assert!(labels.contains("7z 파일을 만들었습니다"), "{labels}");
254추가: assert!(labels.contains("여행 자료.7z.001"), "{labels}");
255추가: assert!(!labels.contains("확인하지 못했습니다"), "{labels}");
256추가: }
257추가: _ => {}
258추가: }
229259 if scenario.name == "extract-complete-cleanup-failed" {
230260 use zipelo_ui_memory_app::archive_ui::{
231261 Cleanup, Disposition, Outcome, Publication,
수정tests/rust-app-ui/scenarios.rs+31-4
@@ -39,12 +39,15 @@ catalog! {
3939 "create-sevenzip-error" => "7z 만들기 저장 실패",
4040 "create-sevenzip-cancelled" => "7z 만들기 취소 완료",
4141 "create-sevenzip-resource" => "7z 만들기의 큰 작업 승인",
42추가: "create-sevenzip-split" => "7z 쪼갤 용량 설정과 볼륨 크기 입력",
43추가: "create-sevenzip-split-invalid" => "잘못된 쪼갤 용량의 오류와 압축하기 비활성화",
44추가: "create-sevenzip-split-complete" => "분할 7z 만들기 완료와 첫 볼륨 경로",
4245
4346 "split-archive" => "분할 7z 목록과 미리보기 비활성화",
4447 "split-first-volume" => "첫 조각의 정확한 파일명 안내",
4548 "split-missing-volume" => "누락 조각 파일명과 재시도 안내",
4649 "split-incomplete" => "누락 이름을 단정하지 않는 불완전 묶음 안내",
47삭제: "split-unsupported" => "분할 ZIP과 RAR 및 분할 생성 미지원 안내",
50추가: "split-unsupported" => "분할 ZIP과 RAR 미지원 안내",
4851 "split-source-changed" => "목록 이후 분할 조각 변경 안내",
4952 "preview-catalog-bytes-approval" => "16 GiB를 넘는 전체 목록의 미리보기 승인",
5053 "preview-catalog-approval" => "미리보기의 전체 목록 처리 예산 승인",
@@ -115,6 +118,11 @@ catalog! {
115118 "uninstall-ubuntu-unknown-user" => "Ubuntu 제거 사용자 확인 불가 안내",
116119}
117120
121추가: /// 만들기 창의 쪼갤 용량 입력을 해석한 결과. 잘못된 입력이면 압축하기가 비활성임.
122추가: pub fn split_volume(app: &ArchiveApp) -> Result<Option<u64>, &'static str> {
123추가: app.split_volume()
124추가: }
125추가:
118126pub fn listing() -> String {
119127 SCENARIOS
120128 .iter()
@@ -582,7 +590,11 @@ impl Scenario {
582590 }
583591 return app;
584592 }
585삭제: "create" | "create-encrypted" | "create-sevenzip" => {
593추가: "create"
594추가: | "create-encrypted"
595추가: | "create-sevenzip"
596추가: | "create-sevenzip-split"
597추가: | "create-sevenzip-split-invalid" => {
586598 app.sources = vec![base.join("읽어주세요.txt"), base.join("사진")];
587599 app.scenario_sources = Some(std::rc::Rc::new(vec![
588600 SourceRow {
@@ -597,7 +609,16 @@ impl Scenario {
597609 },
598610 ]));
599611 app.show_create(self.name == "create-encrypted");
600삭제: app.set_seven_zip(self.name == "create-sevenzip");
612추가: app.set_seven_zip(self.name.starts_with("create-sevenzip"));
613추가: if self.name.starts_with("create-sevenzip-split") {
614추가: app.zip_name = "여행 자료.7z".into();
615추가: app.split = true;
616추가: app.split_amount = if self.name == "create-sevenzip-split" {
617추가: "700".into()
618추가: } else {
619추가: "0".into()
620추가: };
621추가: }
601622 return app;
602623 }
603624 _ => {}
@@ -744,6 +765,7 @@ impl Scenario {
744765 return app;
745766 }
746767 let seven_zip = self.name.starts_with("create-sevenzip");
768추가: let split_complete = self.name == "create-sevenzip-split-complete";
747769 let creating = self.name.starts_with("create-") || self.name == "password-create";
748770 let listing_error = matches!(self.name, "unsupported" | "damaged");
749771 if matches!(self.name, "gzip-conflict" | "gzip-conflict-choice") {
@@ -762,6 +784,7 @@ impl Scenario {
762784 Start::CreateSevenZip {
763785 sources: vec![(base.join("사진"), "사진".into())],
764786 output_file: base.join("여행 자료.7z"),
787추가: volume_size: split_complete.then_some(700 * 1024 * 1024),
765788 }
766789 } else if creating {
767790 Start::CreateZip {
@@ -782,7 +805,10 @@ impl Scenario {
782805 .then(|| app.gzip_name.clone()),
783806 }
784807 };
785삭제: app.targets = Some(if creating {
808추가: app.targets = Some(if split_complete {
809추가: // 완료 보고와 대조하도록 실제 작업자처럼 볼륨 세 개의 이름을 기대함.
810추가: (1..=3).map(|n| format!("여행 자료.7z.{n:03}")).collect()
811추가: } else if creating {
786812 BTreeSet::from([if seven_zip {
787813 "여행 자료.7z"
788814 } else {
@@ -956,6 +982,7 @@ impl Scenario {
956982 "extract-complete"
957983 | "create-complete"
958984 | "create-sevenzip-complete"
985추가: | "create-sevenzip-split-complete"
959986 | "extract-unsynced"
960987 | "extract-complete-cleanup-failed" => {
961988 let names = app.targets.as_ref().unwrap();
수정tests/rust-archive-worker/create_sources.rs+2-0
@@ -127,6 +127,7 @@ fn publication_exception_requires_the_exact_parent_name_and_temporary_object() {
127127 parent: filesystem::object(&Input::open(&s.0.join("folder")).unwrap().file).unwrap(),
128128 name: ".zipelo-owned.tmp".into(),
129129 object: filesystem::object(&Input::open(&path).unwrap().file).unwrap(),
130추가: others: Vec::new(),
130131 };
131132 assert_eq!(plan.verify(&mut || Ok(())), Err(ErrorCode::SourceChanged));
132133 assert_eq!(
@@ -170,6 +171,7 @@ fn publication_directory_enumeration_remains_cancellable() {
170171 parent: filesystem::object(&Input::open(&s.0.join("folder")).unwrap().file).unwrap(),
171172 name: ".zipelo-owned.tmp".into(),
172173 object: filesystem::object(&Input::open(&path).unwrap().file).unwrap(),
174추가: others: Vec::new(),
173175 };
174176 let mut calls = 0;
175177 let result = plan.verify_for_publication(&temporary, &mut || {
수정tests/rust-archive-worker/partial_output.rs+1-0
@@ -65,6 +65,7 @@ fn prepare(s: &Scratch, operation: &str) -> (Start, PathBuf) {
6565 method: SevenZipMethod::Lzma2,
6666 solid: false,
6767 encryption: Encryption::None,
68추가: volume_size: None,
6869 },
6970 s.0.join("result.7z"),
7071 ),
수정tests/rust-archive-worker/seven_zip_create.rs+31-3
@@ -21,6 +21,7 @@ fn request(windows: bool) -> Action {
2121 method: SevenZipMethod::Lzma2,
2222 solid: false,
2323 encryption: Encryption::None,
24추가: volume_size: None,
2425 }
2526}
2627
@@ -104,7 +105,8 @@ fn request_preserves_agreed_field_order_and_native_encodings() {
104105 } else {
105106 expected.extend(b"\x01\x05\x00\x00\x00/o.7z");
106107 }
107삭제: expected.extend([0, 0, 0]);
108추가: // 방식, solid, 암호화, 분할 크기(없음).
109추가: expected.extend([0, 0, 0, 0]);
108110 expected.extend(u64::MAX.to_le_bytes());
109111 expected.extend((16u64 * 1024 * 1024 * 1024).to_le_bytes());
110112 expected.extend(10_000u32.to_le_bytes());
@@ -180,8 +182,14 @@ fn truncated_unknown_and_trailing_creation_fields_are_rejected() {
180182 let mut trailing = body.to_vec();
181183 trailing.push(0);
182184 reject_decode(&raw(1, &trailing));
183삭제: let method = body.len() - 20 - 3;
184삭제: for (at, value) in [(0, 5), (method, 1), (method + 1, 2), (method + 2, 2)] {
185추가: let method = body.len() - 20 - 4;
186추가: for (at, value) in [
187추가: (0, 5),
188추가: (method, 1),
189추가: (method + 1, 2),
190추가: (method + 2, 2),
191추가: (method + 3, 2),
192추가: ] {
185193 let mut body = body.to_vec();
186194 body[at] = value;
187195 reject_decode(&raw(1, &body));
@@ -363,6 +371,7 @@ fn unsupported_options_fail_before_questions_or_file_access() {
363371 method: SevenZipMethod::Lzma2,
364372 solid,
365373 encryption,
374추가: volume_size: None,
366375 };
367376 let start = start(action);
368377 let message = if kind == 1 {
@@ -411,3 +420,22 @@ fn existing_runtime_encryption_capability_is_preserved() {
411420 ));
412421 assert_eq!(terminal(&events).outcome, Outcome::Failed);
413422}
423추가:
424추가: #[test]
425추가: fn split_volume_size_round_trips_and_absence_stays_distinct() {
426추가: for size in [
427추가: None,
428추가: Some(MIN_SEVEN_ZIP_VOLUME_BYTES),
429추가: Some(5 * 1024 * 1024 * 1024),
430추가: ] {
431추가: let mut action = request(false);
432추가: if let Action::CreateSevenZip { volume_size, .. } = &mut action {
433추가: *volume_size = size;
434추가: }
435추가: let start = start(action);
436추가: match decode(&encode(&Message::Start(start.clone()))) {
437추가: Message::Start(actual) => assert_eq!(actual, start),
438추가: other => panic!("{other:?}"),
439추가: }
440추가: }
441추가: }
수정tests/rust-archive-worker/seven_zip_create_fields.rs+30-0
@@ -165,3 +165,33 @@ fn header_metadata_is_charged_before_source_capture() {
165165 ));
166166 std::fs::remove_dir_all(root).unwrap();
167167}
168추가:
169추가: #[test]
170추가: fn split_volume_plan_sizes_names_and_limits() {
171추가: const MIB: u64 = 1024 * 1024;
172추가: let files = volumes("묶음.7z", 2 * MIB + 5, MIB).unwrap();
173추가: assert_eq!(
174추가: files,
175추가: vec![
176추가: ("묶음.7z.001".to_owned(), MIB),
177추가: ("묶음.7z.002".to_owned(), MIB),
178추가: ("묶음.7z.003".to_owned(), 5),
179추가: ]
180추가: );
181추가: // 정확히 나누어떨어지면 빈 마지막 볼륨을 만들지 않음.
182추가: assert_eq!(volumes("a.7z", 2 * MIB, MIB).unwrap().len(), 2);
183추가: assert_eq!(
184추가: volumes("a.7z", 100, MIB).unwrap(),
185추가: vec![("a.7z.001".to_owned(), 100)]
186추가: );
187추가: let last = volumes("a.7z", 999 * MIB, MIB).unwrap();
188추가: assert_eq!(last.len(), 999);
189추가: assert_eq!(last[998].0, "a.7z.999");
190추가: assert_eq!(volumes("a.7z", 999 * MIB + 1, MIB), Err(ErrorCode::Limit));
191추가: assert_eq!(volumes("a.7z", u64::MAX, MIB), Err(ErrorCode::Limit));
192추가: assert_eq!(volumes("a.7z", 10, MIB - 1), Err(ErrorCode::InvalidRequest));
193추가: assert_eq!(volumes("a.7z", 10, 0), Err(ErrorCode::InvalidRequest));
194추가: assert_eq!(volume_name("a.7z", 0), Err(ErrorCode::Limit));
195추가: assert_eq!(volume_name("a.7z", 1000), Err(ErrorCode::Limit));
196추가: assert_eq!(volume_name("a.7z", 42).unwrap(), "a.7z.042");
197추가: }
수정tests/rust-archive-worker/seven_zip_create_runtime.rs+4-0
@@ -45,6 +45,7 @@ impl Case {
4545 method: SevenZipMethod::Lzma2,
4646 solid: false,
4747 encryption: Encryption::None,
48추가: volume_size: None,
4849 },
4950 limits: Limits::default(),
5051 }
@@ -847,3 +848,6 @@ fn gigabyte_creation_stays_below_64_mib_peak_rss() {
847848 .success()
848849 );
849850}
851추가:
852추가: #[path = "seven_zip_split_create.rs"]
853추가: mod split;
추가tests/rust-archive-worker/seven_zip_split_create.rs+347-0
@@ -0,0 +1,347 @@
1추가: // 분할 7z 만들기: 볼륨 이름/크기, 분할 읽기 왕복, 이름 충돌·취소·게시 실패 되돌리기.
2추가: use super::*;
3추가:
4추가: const MIB: u64 = 1024 * 1024;
5추가:
6추가: fn noise(length: usize, mut state: u32) -> Vec<u8> {
7추가: (0..length)
8추가: .map(|_| {
9추가: state ^= state << 13;
10추가: state ^= state >> 17;
11추가: state ^= state << 5;
12추가: state as u8
13추가: })
14추가: .collect()
15추가: }
16추가: fn split_request(c: &Case, names: &[&str], output: &str, size: u64) -> Start {
17추가: let mut start = c.request(names);
18추가: if let Action::CreateSevenZip {
19추가: output_file,
20추가: volume_size,
21추가: ..
22추가: } = &mut start.action
23추가: {
24추가: *output_file = NativePath::from_path(&c.0.join(output));
25추가: *volume_size = Some(size);
26추가: }
27추가: start
28추가: }
29추가: fn volume_files(dir: &std::path::Path, prefix: &str) -> Vec<String> {
30추가: let mut names = fs::read_dir(dir)
31추가: .unwrap()
32추가: .map(|entry| entry.unwrap().file_name().to_string_lossy().into_owned())
33추가: .filter(|name| name.starts_with(prefix))
34추가: .collect::<Vec<_>>();
35추가: names.sort();
36추가: names
37추가: }
38추가: fn created(events: &[Message]) -> Vec<String> {
39추가: events
40추가: .iter()
41추가: .filter_map(|event| match event {
42추가: Message::Output {
43추가: entry_id: None,
44추가: relative_name,
45추가: disposition: Disposition::Created,
46추가: } => Some(relative_name.clone()),
47추가: _ => None,
48추가: })
49추가: .collect()
50추가: }
51추가: fn no_temporaries(dir: &std::path::Path) {
52추가: assert!(!tree(dir).keys().any(|name| name.contains(".zipelo-")));
53추가: }
54추가:
55추가: #[test]
56추가: fn split_volumes_have_requested_sizes_and_round_trip_through_the_split_reader() {
57추가: for parent in ["", "source"] {
58추가: let c = Case::new();
59추가: private_dir(&c.0.join("source"));
60추가: private_dir(&c.0.join("source/빈 폴더"));
61추가: fs::write(
62추가: c.0.join("source/noise.bin"),
63추가: noise(2 * MIB as usize + 300_000, 7),
64추가: )
65추가: .unwrap();
66추가: fs::write(c.0.join("source/한글.txt"), "분할 압축\n".repeat(2000)).unwrap();
67추가: fs::write(c.0.join("source/empty"), b"").unwrap();
68추가: let expected = tree(&c.0.join("source"));
69추가: let output = if parent.is_empty() {
70추가: "result.7z".to_owned()
71추가: } else {
72추가: format!("{parent}/result.7z")
73추가: };
74추가: let events = c.run(Message::Start(split_request(&c, &["source"], &output, MIB)));
75추가: let t = terminal(&events);
76추가: assert_eq!(t.outcome, Outcome::Completed, "{events:?}");
77추가: assert_eq!(t.publication, Publication::Complete);
78추가: assert_eq!(t.created_count, 3);
79추가: assert_eq!(t.cleanup, Cleanup::Complete);
80추가: assert_eq!(t.retained_partial_count, 0);
81추가: assert_eq!(
82추가: created(&events),
83추가: ["result.7z.001", "result.7z.002", "result.7z.003"]
84추가: );
85추가: let dir = c.0.join(parent);
86추가: assert!(!dir.join("result.7z").exists());
87추가: assert_eq!(
88추가: volume_files(&dir, "result.7z"),
89추가: ["result.7z.001", "result.7z.002", "result.7z.003"]
90추가: );
91추가: let sizes = ["001", "002", "003"].map(|n| {
92추가: fs::metadata(dir.join(format!("result.7z.{n}")))
93추가: .unwrap()
94추가: .len()
95추가: });
96추가: assert_eq!(sizes[0], MIB);
97추가: assert_eq!(sizes[1], MIB);
98추가: assert!(sizes[2] > 0 && sizes[2] <= MIB, "{sizes:?}");
99추가: // 볼륨을 이어 붙이면 그대로 하나의 7z임.
100추가: let mut joined = Vec::new();
101추가: for n in ["001", "002", "003"] {
102추가: joined.extend(fs::read(dir.join(format!("result.7z.{n}"))).unwrap());
103추가: }
104추가: assert_eq!(&joined[..6], b"7z\xbc\xaf\x27\x1c");
105추가: no_temporaries(&c.0);
106추가:
107추가: let first = NativePath::from_path(&dir.join("result.7z.001"));
108추가: let listed = c.run(Message::Start(Start {
109추가: action: Action::List {
110추가: archive: first.clone(),
111추가: },
112추가: limits: Limits::default(),
113추가: }));
114추가: assert_eq!(terminal(&listed).outcome, Outcome::Completed, "{listed:?}");
115추가: assert!(listed.iter().any(|event| matches!(
116추가: event,
117추가: Message::ListEnd {
118추가: list_id: ListId {
119추가: source_object: SourceObject::SplitSevenZip { .. },
120추가: ..
121추가: },
122추가: ..
123추가: }
124추가: )));
125추가: private_dir(&c.0.join("decoded"));
126추가: let extracted = c.run(Message::Start(Start {
127추가: action: Action::Extract {
128추가: archive: first,
129추가: destination: c.path("decoded"),
130추가: selection: Selection::All,
131추가: list_id: None,
132추가: gzip_output_name: None,
133추가: },
134추가: limits: Limits::default(),
135추가: }));
136추가: assert_eq!(
137추가: terminal(&extracted).outcome,
138추가: Outcome::Completed,
139추가: "{extracted:?}"
140추가: );
141추가: assert_eq!(tree(&c.0.join("decoded/source")), expected);
142추가: if let Some(tool) = std::env::var_os("ZIPELO_TEST_7ZIP") {
143추가: let output = Command::new(&tool)
144추가: .arg("t")
145추가: .arg(dir.join("result.7z.001"))
146추가: .output()
147추가: .unwrap();
148추가: assert!(output.status.success(), "{output:?}");
149추가: let output = Command::new(tool)
150추가: .args(["x", "-y"])
151추가: .arg(dir.join("result.7z.001"))
152추가: .arg(format!("-o{}", c.0.join("independent").display()))
153추가: .output()
154추가: .unwrap();
155추가: assert!(output.status.success(), "{output:?}");
156추가: assert_eq!(tree(&c.0.join("independent/source")), expected);
157추가: }
158추가: }
159추가: }
160추가:
161추가: #[test]
162추가: fn small_archives_still_use_a_single_first_volume_name() {
163추가: let c = Case::new();
164추가: fs::write(c.0.join("source"), b"small payload").unwrap();
165추가: let events = c.run(Message::Start(split_request(
166추가: &c,
167추가: &["source"],
168추가: "작은.7z",
169추가: 4 * MIB,
170추가: )));
171추가: assert_eq!(terminal(&events).outcome, Outcome::Completed, "{events:?}");
172추가: assert_eq!(terminal(&events).created_count, 1);
173추가: assert_eq!(created(&events), ["작은.7z.001"]);
174추가: assert_eq!(volume_files(&c.0, "작은.7z"), ["작은.7z.001"]);
175추가: let listed = c.run(Message::Start(Start {
176추가: action: Action::List {
177추가: archive: c.path("작은.7z.001"),
178추가: },
179추가: limits: Limits::default(),
180추가: }));
181추가: assert_eq!(terminal(&listed).outcome, Outcome::Completed, "{listed:?}");
182추가: }
183추가:
184추가: #[test]
185추가: fn invalid_sizes_names_and_existing_volume_names_are_rejected() {
186추가: let c = Case::new();
187추가: fs::write(c.0.join("source"), b"abcdef").unwrap();
188추가: for size in [0, 1, MIB - 1] {
189추가: failure(
190추가: &c.run(Message::Start(split_request(
191추가: &c,
192추가: &["source"],
193추가: "result.7z",
194추가: size,
195추가: ))),
196추가: ErrorCode::InvalidRequest,
197추가: );
198추가: }
199추가: failure(
200추가: &c.run(Message::Start(split_request(
201추가: &c,
202추가: &["source"],
203추가: "result.zip",
204추가: MIB,
205추가: ))),
206추가: ErrorCode::InvalidRequest,
207추가: );
208추가: // 분할 읽기는 자릿수와 관계없이 같은 접두사의 숫자 이름을 한 묶음으로 보므로 모두 거부함.
209추가: for existing in [
210추가: "result.7z.001",
211추가: "result.7z.002",
212추가: "result.7z.0001",
213추가: "result.7z.5",
214추가: ] {
215추가: fs::write(c.0.join(existing), b"preserve").unwrap();
216추가: failure(
217추가: &c.run(Message::Start(split_request(
218추가: &c,
219추가: &["source"],
220추가: "result.7z",
221추가: MIB,
222추가: ))),
223추가: ErrorCode::Conflict,
224추가: );
225추가: assert_eq!(fs::read(c.0.join(existing)).unwrap(), b"preserve");
226추가: assert_eq!(volume_files(&c.0, "result.7z"), [existing]);
227추가: fs::remove_file(c.0.join(existing)).unwrap();
228추가: }
229추가: // 숫자가 아닌 비슷한 이름과 분할하지 않은 같은 이름은 그대로 두고 만듦.
230추가: fs::write(c.0.join("result.7z"), b"single").unwrap();
231추가: fs::write(c.0.join("result.7z.bak"), b"backup").unwrap();
232추가: let events = c.run(Message::Start(split_request(
233추가: &c,
234추가: &["source"],
235추가: "result.7z",
236추가: MIB,
237추가: )));
238추가: assert_eq!(terminal(&events).outcome, Outcome::Completed, "{events:?}");
239추가: assert_eq!(fs::read(c.0.join("result.7z")).unwrap(), b"single");
240추가: assert!(c.0.join("result.7z.001").is_file());
241추가: no_temporaries(&c.0);
242추가: }
243추가:
244추가: #[test]
245추가: fn cancel_while_writing_volumes_publishes_nothing() {
246추가: let c = Case::new();
247추가: fs::write(c.0.join("source"), noise(3 * MIB as usize, 11)).unwrap();
248추가: let mut sent = false;
249추가: let events = c.run_with(
250추가: &mut c.command(),
251추가: Message::Start(split_request(&c, &["source"], "result.7z", MIB)),
252추가: |event| {
253추가: // 볼륨 게시 단계의 첫 쓰기 진행(전체 길이가 있는 Write)에서 취소함.
254추가: if !sent
255추가: && matches!(
256추가: event,
257추가: Message::Progress {
258추가: stage: Stage::Write,
259추가: total_bytes: Some(_),
260추가: ..
261추가: }
262추가: )
263추가: {
264추가: sent = true;
265추가: vec![Message::Cancel]
266추가: } else {
267추가: Vec::new()
268추가: }
269추가: },
270추가: );
271추가: assert!(sent);
272추가: failure(&events, ErrorCode::None);
273추가: assert!(volume_files(&c.0, "result.7z").is_empty());
274추가: no_temporaries(&c.0);
275추가: }
276추가:
277추가: #[cfg(target_os = "linux")]
278추가: #[test]
279추가: fn a_volume_name_taken_during_publication_rolls_back_every_volume() {
280추가: for operation in ["second", "source", "cancel"] {
281추가: let c = Case::new();
282추가: fs::write(c.0.join("source"), noise(2 * MIB as usize + 1000, 3)).unwrap();
283추가: let marker = c.0.join("marker");
284추가: let release = c.0.join("release");
285추가: let mut command = c.command();
286추가: command
287추가: .env("LD_PRELOAD", shim(&c, "io_fault.c"))
288추가: .env("ZIPELO_TEST_FAULT", "pause")
289추가: .env("ZIPELO_TEST_MARKER", &marker)
290추가: .env("ZIPELO_TEST_RELEASE", &release);
291추가: let mut changed = false;
292추가: let events = c.run_with(
293추가: &mut command,
294추가: Message::Start(split_request(&c, &["source"], "result.7z", MIB)),
295추가: |event| {
296추가: if !changed
297추가: && matches!(
298추가: event,
299추가: Message::Progress {
300추가: stage: Stage::Write,
301추가: total_bytes: Some(_),
302추가: ..
303추가: }
304추가: )
305추가: {
306추가: let until = std::time::Instant::now() + Duration::from_secs(5);
307추가: while !marker.exists() {
308추가: assert!(std::time::Instant::now() < until);
309추가: std::thread::sleep(Duration::from_millis(2));
310추가: }
311추가: match operation {
312추가: // 첫 볼륨은 게시할 수 있지만 둘째 이름이 막혀 첫 볼륨도 되돌려야 함.
313추가: "second" => fs::write(c.0.join("result.7z.002"), b"user data").unwrap(),
314추가: "source" => fs::write(c.0.join("source"), b"changed").unwrap(),
315추가: _ => {}
316추가: }
317추가: changed = true;
318추가: let replies = if operation == "cancel" {
319추가: vec![Message::Cancel]
320추가: } else {
321추가: Vec::new()
322추가: };
323추가: fs::write(&release, b"resume").unwrap();
324추가: replies
325추가: } else {
326추가: Vec::new()
327추가: }
328추가: },
329추가: );
330추가: assert!(changed);
331추가: failure(
332추가: &events,
333추가: match operation {
334추가: "second" => ErrorCode::Conflict,
335추가: "source" => ErrorCode::SourceChanged,
336추가: _ => ErrorCode::None,
337추가: },
338추가: );
339추가: if operation == "second" {
340추가: assert_eq!(volume_files(&c.0, "result.7z"), ["result.7z.002"]);
341추가: assert_eq!(fs::read(c.0.join("result.7z.002")).unwrap(), b"user data");
342추가: } else {
343추가: assert!(volume_files(&c.0, "result.7z").is_empty());
344추가: }
345추가: no_temporaries(&c.0);
346추가: }
347추가: }