team-ljyzipelo

공개

원본 폴더 내부 저장 오탐을 수정함

작성자
시로사키 하나
작성 시각
커밋
eec85f32b6adf89c0561260d908b8edfd0ec95e3
부모
71aa755
이 시점의 파일 보기

변경된 파일 6개

+381-18
수정docs/sevenzip-create-design.md+3-3
@@ -67,12 +67,12 @@
67671. 목적지 부모를 기존 Dir로 고정하고 경로/기존 목적지를 사전 검사한다. 원본과 같은 이름, 기존 파일/링크에는 쓰지 않는다.
68682. 원본 계획과 소스 스냅샷을 만들고 비공개 spool 임시 파일에 완성된 7z를 작성한다. finish, 구조 검사와 Plan::verify가 실패하면 게시하지 않는다.
69693. 완성 길이에 맞춰 목적지 공간을 확인하고 기존 publish_reader_steps의 새 파일 경로(replace=None)에 전달한다. 파일 sync와 close 오류를 확인한 뒤 배타적으로 게시한다. 사전검사 뒤 나타난 목적지도 Conflict로 거부한다.
70삭제: 4. 게시 직전에도 계획과 취소를 확인하며 확인과 게시 사이의 원자적 트랜잭션을 약속하지 않는다. 게시 후 부모 sync와 정리 결과를 실제 내구성/부분 출력으로 보고한다. 불명확한 결과를 덮어 재시도하지 않는다.
70추가: 4. 게시 직전에도 계획과 취소를 확인한다. 원본 폴더 안에 저장할 때는 게시 임시 파일 부모의 객체 ID를 계획과 대조하고, 그 폴더만 수정 시각 대신 원래 자식 목록을 다시 확인한다. 원래 목록은 탐색 때 이미 예산에 반영한 이름을 보존한다. 게시자가 열린 파일에서 기록한 정확한 임시 이름과 객체 ID 하나만 제외하며, 같은 접두 이름의 사용자 파일, 원본 추가/누락/이름 변경과 기존 항목의 객체/종류/크기/수정 시각 변경은 거부한다. 열거 전후 폴더 시각이 바뀌어도 거부한다. 확인과 게시 사이의 원자적 트랜잭션이나 잠깐 추가됐다 사라진 항목까지 감지한다고 약속하지 않는다. 게시 후 부모 sync와 정리 결과를 실제 내구성/부분 출력으로 보고한다. 불명확한 결과를 덮어 재시도하지 않는다.
71715. 비공개 입력/생성물은 핸들을 닫아 제거하고 목적지 임시 파일만 기존 소유 확인 정책으로 정리한다. 무관한 파일이나 이미 게시한 파일을 삭제하지 않는다. 강제 종료/전원 손실 뒤 자동 정리까지 보장하지 않는다.
7272
7373## 7. 구현 후 수용 시험
7474
75삭제: 아래는 수용 시험 기준이다. Linux에서 새 정수/비트맵과 인코딩 경계, 독립 7-Zip 26.00/Zipelo의 한글/보조 평면 이름 및 빈 구조 왕복, 취소/쓰기/finish/헤더 seek와 패치/게시 실패를 검증했다. 1 GiB 대표 생성은 11,168 KiB RSS와 약 20.8초를 기록했다. 이는 단일 표본 측정이며 모든 입력의 성능이나 OS 강제 상한이 아니다. 전체 local, 라이선스 시험과 플랫폼별 수행 결과는 PR 본문과 tests/work/7zc의 로그를 따른다. Windows/Wayland 실제 생성 통합과 구현 독립 리뷰는 아직 남았다. 시험 코드는 루트 tests/에만 두며 일회성 자료, 도구, 캐시와 로그는 tests/work/7zc 한 곳에 모은다. TMPDIR과 CARGO_TARGET_DIR을 그 하위에 명시하고 사본 안에 작업 폴더나 빌드 캐시를 다시 만들지 않는다. PR 병합/종료 뒤 담당자가 정리한다.
75추가: 아래는 수용 시험 기준이다. Linux에서 새 정수/비트맵과 인코딩 경계, 독립 7-Zip 26.00/Zipelo의 한글/보조 평면 이름 및 빈 구조 왕복, 취소/쓰기/finish/헤더 seek와 패치/게시 실패를 검증했다. 1 GiB 대표 생성은 11,168 KiB RSS와 약 20.8초를 기록했다. 이는 단일 표본 측정이며 모든 입력의 성능이나 OS 강제 상한이 아니다. 전체 local, 라이선스 시험과 플랫폼별 수행 결과는 PR 본문과 tests/work/7zc의 로그를 따른다. 71aa755의 Windows/Wayland 실제 생성 통합은 PR 본문에 기록되어 있다. 내부 저장 오탐 수정 뒤의 GUI 실기는 재실행하지 않았으며 독립 재리뷰는 남았다. 시험 코드는 루트 tests/에만 두며 일회성 자료, 도구, 캐시와 로그는 tests/work/7zc 한 곳에 모은다. TMPDIR과 CARGO_TARGET_DIR을 그 하위에 명시하고 사본 안에 작업 폴더나 빌드 캐시를 다시 만들지 않는다. PR 병합/종료 뒤 담당자가 정리한다.
7676
7777- 일반 파일, 압축되는/난수 내용, 한글 및 여러 단계 경로, 혼합 파일/폴더, 빈 파일, 빈 폴더, 빈 폴더만 있는 묶음과 여러 최상위 원본을 만든다. Zipelo 목록/해제와 독립 7-Zip의 테스트/목록/해제를 각각 실행해 상대 경로, 항목 종류, 파일 크기와 SHA256을 원본 manifest와 대조한다. 압축 아카이브 바이트 자체의 일치는 요구하지 않는다.
7878- 독립 설계 리뷰의 후속 기준으로 MainStreamsInfo/kEnd 계층, 32바이트 기준 NextHeaderOffset, 가변 UINT64와 고정 REAL_UINT64 구분을 확인한다. EmptyFile 비트 수는 전체 파일 수가 아닌 empty stream 수이며 혼합 빈 항목 7/8/9개와 정수 경계 127/128, 16383/16384를 포함한다.
@@ -87,4 +87,4 @@
8787- 하나는 이 계약과 backend 작성기, 공용 타입/codec 및 작업자 회귀를 담당한다. 히나타의 계약 동의와 카논의 설계 리뷰가 확인되어 공용 타입 인계 단계에 착수했다. 실제 작성기를 반영했으며 새 파일로 Windows/Wayland 통합 검증을 인계한다.
8888- 계약 동의 뒤 공용 타입 반영 커밋을 히나타에게 전달한다. 히나타는 기존 생성 화면의 ZIP/7z 형식 선택, .7z 기본 저장 형식, 암호/방식 선택 제한, 새 ActionKind 변환과 수신 검증을 담당한다. 화면이 바뀌는 구현 PR에 --ui-scenario 목록/시험과 docs/ui-scenario-guide.md를 함께 갱신한다. 별도 디자인 변경이나 애니메이션을 추가하지 않는다.
8989- 카논의 설계와 실패 경계 리뷰는 완료되었으며 구현 후 독립 7-Zip 호환 검증 및 재리뷰는 별도 요청한다. 도구 버전/옵션, 원본과 해제 manifest 및 플랫폼별 실행 범위를 남긴다. 도구를 제품에 번들하지 않는다.
90삭제: - 설계 문서의 정적 검토와 링크/공백 검사는 제품 빌드나 호환 검증이 아니다. 이번 backend 추가분은 UI 변경 없음이다. 같은 PR의 형식 선택과 시나리오는 이미 반영되어 있으며 실제 파일의 Windows/Wayland 통합 및 구현 독립 리뷰가 끝날 때까지 초안을 유지한다.
90추가: - 설계 문서의 정적 검토와 링크/공백 검사는 제품 빌드나 호환 검증이 아니다. 이번 backend 추가분은 UI 변경 없음이다. 같은 PR의 형식 선택과 시나리오는 이미 반영되었고 71aa755에서 Windows/Wayland 실제 파일 통합을 확인했다. 내부 저장 오탐 수정 뒤 독립 재리뷰가 끝날 때까지 초안을 유지한다.
수정experiments/rust-archive-worker/src/create_sources.rs+73-3
@@ -180,6 +180,7 @@ pub(super) struct Planned {
180180 path: PathBuf,
181181 object: SourceObject,
182182 modified: Option<SystemTime>,
183추가: children: Vec<String>,
183184}
184185impl Planned {
185186 pub fn open(&self) -> Result<Input> {
@@ -196,6 +197,56 @@ impl Planned {
196197 && metadata.is_dir() == (self.member.entry.kind == EntryKind::Directory)
197198 && (metadata.is_dir() || metadata.len() == self.member.entry.size))
198199 }
200추가: fn verify_with_temporary(
201추가: &self,
202추가: temporary: &filesystem::PublicationTemp,
203추가: check: &mut impl crate::resources::Monitor,
204추가: ) -> Result<()> {
205추가: let input = Input::open(&self.path).map_err(|_| ErrorCode::SourceChanged)?;
206추가: let before = input.file.metadata().map_err(crate::space::io_error)?;
207추가: if !before.is_dir() || filesystem::object(&input.file)? != self.object {
208추가: return Err(ErrorCode::SourceChanged);
209추가: }
210추가: // 게시 임시 파일의 부모만 시각 대신 원래 항목과 소유 객체를 대조함.
211추가: let mut count = 0;
212추가: let mut found = false;
213추가: for entry in input.children(&self.path)? {
214추가: check.check()?;
215추가: let name = entry.map_err(crate::space::io_error)?.file_name();
216추가: let name = name.to_str().ok_or(ErrorCode::SourceChanged)?;
217추가: if name == temporary.name {
218추가: let child = input
219추가: .open_child(&self.path, name)
220추가: .map_err(|_| ErrorCode::SourceChanged)?;
221추가: if found
222추가: || !child
223추가: .file
224추가: .metadata()
225추가: .map_err(crate::space::io_error)?
226추가: .is_file()
227추가: || filesystem::object(&child.file)? != temporary.object
228추가: {
229추가: return Err(ErrorCode::SourceChanged);
230추가: }
231추가: found = true;
232추가: } else if self
233추가: .children
234추가: .binary_search_by(|leaf| leaf.as_str().cmp(name))
235추가: .is_ok()
236추가: {
237추가: count += 1;
238추가: } else {
239추가: return Err(ErrorCode::SourceChanged);
240추가: }
241추가: crate::resources::completed(Ok(()), check)?;
242추가: }
243추가: let after = input.file.metadata().map_err(crate::space::io_error)?;
244추가: if !found || count != self.children.len() || before.modified().ok() != after.modified().ok()
245추가: {
246추가: return Err(ErrorCode::SourceChanged);
247추가: }
248추가: Ok(())
249추가: }
199250}
200251pub(super) struct Plan {
201252 pub items: Vec<Planned>,
@@ -283,6 +334,7 @@ impl Plan {
283334 None,
284335 )?;
285336 crate::resources::completed(Ok(()), check)?;
337추가: let index = self.items.len();
286338 self.items.push(Planned {
287339 member: Member {
288340 entry: Entry {
@@ -302,6 +354,7 @@ impl Plan {
302354 path: path.clone(),
303355 object: crate::resources::completed(filesystem::object(&input.file), check)?,
304356 modified: metadata.modified().ok(),
357추가: children: Vec::new(),
305358 });
306359 if directory {
307360 let mut children = Vec::new();
@@ -328,10 +381,11 @@ impl Plan {
328381 crate::resources::completed(Ok(()), check)?;
329382 }
330383 children.sort();
331삭제: for leaf in children {
332삭제: let child = crate::resources::completed(input.open_child(&path, &leaf), check)?;
333삭제: self.visit(path.join(&leaf), format!("{name}/{leaf}"), child, check)?;
384추가: for leaf in &children {
385추가: let child = crate::resources::completed(input.open_child(&path, leaf), check)?;
386추가: self.visit(path.join(leaf), format!("{name}/{leaf}"), child, check)?;
334387 }
388추가: self.items[index].children = children;
335389 }
336390 Ok(())
337391 }
@@ -350,6 +404,22 @@ impl Plan {
350404 }
351405 Ok(())
352406 }
407추가: pub fn verify_for_publication(
408추가: &self,
409추가: temporary: &filesystem::PublicationTemp,
410추가: check: &mut impl crate::resources::Monitor,
411추가: ) -> Result<()> {
412추가: for item in &self.items {
413추가: check.check()?;
414추가: if item.member.entry.kind == EntryKind::Directory && item.object == temporary.parent {
415추가: item.verify_with_temporary(temporary, check)?;
416추가: } else {
417추가: item.open()?;
418추가: }
419추가: crate::resources::completed(Ok(()), check)?;
420추가: }
421추가: Ok(())
422추가: }
353423}
354424
355425#[cfg(test)]
수정experiments/rust-archive-worker/src/filesystem.rs+16-5
@@ -615,7 +615,7 @@ pub(crate) fn directory_with(
615615 check: &mut impl Monitor,
616616) -> Result<(bool, Durability, Option<ErrorCode>)> {
617617 directory_steps(root, name, &mut |step| match step {
618삭제: PublishStep::Check | PublishStep::Commit => check.check(),
618추가: PublishStep::Check | PublishStep::Commit(_) => check.check(),
619619 PublishStep::Activity => check.activity(),
620620 })
621621}
@@ -629,7 +629,7 @@ pub(crate) fn directory_steps(
629629 if completed(d.child(&leaf, false), &mut PublicationMonitor(check))?.is_some() {
630630 return Ok((false, Durability::NotApplicable, None));
631631 }
632삭제: check(PublishStep::Commit)?;
632추가: check(PublishStep::Commit(None))?;
633633 d.child(&leaf, true)?.ok_or(ErrorCode::Io)?;
634634 let progress_error = completed(Ok(()), &mut PublicationMonitor(check)).err();
635635 Ok(match d.sync_checked() {
@@ -684,14 +684,19 @@ pub fn publish_reader_mode(
684684) -> Published {
685685 publish_reader_steps(root, name, data, length, replace, &mut |step| match step {
686686 PublishStep::Check => check(false),
687삭제: PublishStep::Commit => check(true),
687추가: PublishStep::Commit(_) => check(true),
688688 PublishStep::Activity => Ok(()),
689689 })
690690}
691추가: pub(crate) struct PublicationTemp {
692추가: pub parent: SourceObject,
693추가: pub name: String,
694추가: pub object: SourceObject,
695추가: }
691696pub(crate) enum PublishStep {
692697 Check,
693698 Activity,
694삭제: Commit,
699추가: Commit(Option<PublicationTemp>),
695700}
696701struct PublicationMonitor<'a, F>(&'a mut F);
697702impl<F: FnMut(PublishStep) -> Result<()>> Monitor for PublicationMonitor<'_, F> {
@@ -744,7 +749,13 @@ pub(crate) fn publish_reader_steps(
744749 crate::space::io_error(e)
745750 }
746751 })?;
752추가: let mut temporary = None;
747753 let written = (|| {
754추가: temporary = Some(PublicationTemp {
755추가: parent: object(dir.handle())?,
756추가: name: temp.clone(),
757추가: object: object(&file)?,
758추가: });
748759 completed(Ok(()), &mut PublicationMonitor(check))?;
749760 completed(
750761 crate::space::ensure(&file, length),
@@ -780,7 +791,7 @@ pub(crate) fn publish_reader_steps(
780791 &mut PublicationMonitor(check),
781792 );
782793 let mut finish = written.and(closed).and_then(|_| {
783삭제: check(PublishStep::Commit)?;
794추가: check(PublishStep::Commit(temporary))?;
784795 // 긴 원본 재검증 중 바뀐 대상은 교체 직전에 거부함.
785796 if let Some(expected) = replace {
786797 if completed(dir.existing(&leaf), &mut PublicationMonitor(check))?.as_ref()
수정experiments/rust-archive-worker/src/runtime.rs+11-5
@@ -284,10 +284,16 @@ impl<W: Write> Job<W> {
284284 self.source_group = Some(group);
285285 self.split_result(result)
286286 }
287삭제: fn verify_before_publication(&mut self) -> Result<()> {
287추가: fn verify_before_publication(
288추가: &mut self,
289추가: temporary: Option<&filesystem::PublicationTemp>,
290추가: ) -> Result<()> {
288291 if !self.source_verified_for_publication {
289292 if let Some(plan) = self.creation_plan.take() {
290삭제: let result = plan.verify(self);
293추가: let result = match temporary {
294추가: Some(temporary) => plan.verify_for_publication(temporary, self),
295추가: None => plan.verify(self),
296추가: };
291297 self.creation_plan = Some(plan);
292298 result?;
293299 }
@@ -300,8 +306,8 @@ impl<W: Write> Job<W> {
300306 match step {
301307 filesystem::PublishStep::Check => self.check(),
302308 filesystem::PublishStep::Activity => completed(Ok(()), self),
303삭제: filesystem::PublishStep::Commit => {
304삭제: self.verify_before_publication()?;
309추가: filesystem::PublishStep::Commit(temporary) => {
310추가: self.verify_before_publication(temporary.as_ref())?;
305311 if let Some(plan) = &self.creation_plan {
306312 self.progress(Stage::Commit, 0, None, plan.items.len() as u32)?;
307313 }
@@ -888,7 +894,7 @@ impl<W: Write> Job<W> {
888894 )?;
889895 }
890896 // 건너뛰기 등 실제 게시가 없을 때도 완료 전에 원본을 확인함.
891삭제: self.verify_before_publication()?;
897추가: self.verify_before_publication(None)?;
892898 if !self.interactive || self.terminal.created_count != 0 {
893899 self.terminal.publication = Publication::Complete;
894900 }
수정tests/rust-archive-worker/create_sources.rs+80-2
@@ -4,8 +4,9 @@ static NEXT: AtomicU64 = AtomicU64::new(0);
44struct Scratch(PathBuf);
55impl Scratch {
66 fn new() -> Self {
7삭제: let root =
8삭제: Path::new(env!("CARGO_MANIFEST_DIR")).join("../../tests/rust-archive-worker/runs");
7추가: let root = std::env::var_os("TMPDIR")
8추가: .map(PathBuf::from)
9추가: .unwrap_or_else(|| Path::new(env!("CARGO_MANIFEST_DIR")).join("../../tests/work/tmp"));
910 fs::create_dir_all(&root).unwrap();
1011 let path = root.join(format!(
1112 "sources-{}-{}",
@@ -105,3 +106,80 @@ fn pinned_directory_enumeration_does_not_follow_replacement_link() {
105106 assert!(input.open_child(&path, "secret").is_err());
106107 assert!(matches!(Input::open(&path), Err(ErrorCode::UnsafePath)));
107108}
109추가:
110추가: #[test]
111추가: fn publication_exception_requires_the_exact_parent_name_and_temporary_object() {
112추가: for mismatch in [
113추가: "parent",
114추가: "name",
115추가: "object",
116추가: "missing",
117추가: "replacement",
118추가: "directory",
119추가: ] {
120추가: let s = Scratch::new();
121추가: fs::create_dir(s.0.join("folder")).unwrap();
122추가: fs::write(s.0.join("folder/source"), b"original").unwrap();
123추가: let plan = Plan::new(&[s.source("folder")], Limits::default(), &mut || Ok(())).unwrap();
124추가: let path = s.0.join("folder/.zipelo-owned.tmp");
125추가: fs::write(&path, b"archive").unwrap();
126추가: let mut temporary = filesystem::PublicationTemp {
127추가: parent: filesystem::object(&Input::open(&s.0.join("folder")).unwrap().file).unwrap(),
128추가: name: ".zipelo-owned.tmp".into(),
129추가: object: filesystem::object(&Input::open(&path).unwrap().file).unwrap(),
130추가: };
131추가: assert_eq!(plan.verify(&mut || Ok(())), Err(ErrorCode::SourceChanged));
132추가: assert_eq!(
133추가: plan.verify_for_publication(&temporary, &mut || Ok(())),
134추가: Ok(())
135추가: );
136추가: match mismatch {
137추가: "parent" => temporary.parent = temporary.object.clone(),
138추가: "name" => temporary.name = ".zipelo-other.tmp".into(),
139추가: "object" => temporary.object = temporary.parent.clone(),
140추가: "missing" => fs::remove_file(&path).unwrap(),
141추가: "replacement" => {
142추가: fs::rename(&path, s.0.join("owned")).unwrap();
143추가: fs::write(&path, b"foreign").unwrap();
144추가: }
145추가: "directory" => {
146추가: fs::rename(s.0.join("folder"), s.0.join("previous")).unwrap();
147추가: fs::create_dir(s.0.join("folder")).unwrap();
148추가: }
149추가: _ => unreachable!(),
150추가: }
151추가: assert_eq!(
152추가: plan.verify_for_publication(&temporary, &mut || Ok(())),
153추가: Err(ErrorCode::SourceChanged),
154추가: "{mismatch}"
155추가: );
156추가: }
157추가: }
158추가:
159추가: #[test]
160추가: fn publication_directory_enumeration_remains_cancellable() {
161추가: let s = Scratch::new();
162추가: fs::create_dir(s.0.join("folder")).unwrap();
163추가: for index in 0..20 {
164추가: fs::write(s.0.join(format!("folder/{index}")), b"x").unwrap();
165추가: }
166추가: let plan = Plan::new(&[s.source("folder")], Limits::default(), &mut || Ok(())).unwrap();
167추가: let path = s.0.join("folder/.zipelo-owned.tmp");
168추가: fs::write(&path, b"archive").unwrap();
169추가: let temporary = filesystem::PublicationTemp {
170추가: parent: filesystem::object(&Input::open(&s.0.join("folder")).unwrap().file).unwrap(),
171추가: name: ".zipelo-owned.tmp".into(),
172추가: object: filesystem::object(&Input::open(&path).unwrap().file).unwrap(),
173추가: };
174추가: let mut calls = 0;
175추가: let result = plan.verify_for_publication(&temporary, &mut || {
176추가: calls += 1;
177추가: if calls == 12 {
178추가: Err(ErrorCode::None)
179추가: } else {
180추가: Ok(())
181추가: }
182추가: });
183추가: assert_eq!(result, Err(ErrorCode::None));
184추가: assert_eq!(calls, 12);
185추가: }
수정tests/rust-archive-worker/seven_zip_create_runtime.rs+198-0
@@ -227,6 +227,64 @@ fn tree(root: &std::path::Path) -> std::collections::BTreeMap<String, Option<[u8
227227 result
228228}
229229
230추가: #[test]
231추가: fn saving_outside_inside_and_nested_in_source_preserves_the_original_tree() {
232추가: for parent in ["", "source", "source/nested"] {
233추가: let c = Case::new();
234추가: private_dir(&c.0.join("source"));
235추가: private_dir(&c.0.join("source/nested"));
236추가: private_dir(&c.0.join("source/nested/empty"));
237추가: fs::write(c.0.join("source/한글.txt"), b"original").unwrap();
238추가: fs::write(c.0.join("source/nested/empty.txt"), b"").unwrap();
239추가: let expected = tree(&c.0.join("source"));
240추가: let archive = NativePath::from_path(&c.0.join(parent).join("result.7z"));
241추가: let mut request = c.request(&["source"]);
242추가: if let Action::CreateSevenZip { output_file, .. } = &mut request.action {
243추가: *output_file = archive.clone();
244추가: }
245추가: success(&c.run(Message::Start(request)));
246추가: let listed = c.run(Message::Start(Start {
247추가: action: Action::List {
248추가: archive: archive.clone(),
249추가: },
250추가: limits: Limits::default(),
251추가: }));
252추가: assert_eq!(terminal(&listed).outcome, Outcome::Completed, "{listed:?}");
253추가: private_dir(&c.0.join("decoded"));
254추가: let extracted = c.run(Message::Start(Start {
255추가: action: Action::Extract {
256추가: archive: archive.clone(),
257추가: destination: c.path("decoded"),
258추가: selection: Selection::All,
259추가: list_id: None,
260추가: gzip_output_name: None,
261추가: },
262추가: limits: Limits::default(),
263추가: }));
264추가: assert_eq!(
265추가: terminal(&extracted).outcome,
266추가: Outcome::Completed,
267추가: "{extracted:?}"
268추가: );
269추가: assert_eq!(tree(&c.0.join("decoded/source")), expected);
270추가: if let Some(tool) = std::env::var_os("ZIPELO_TEST_7ZIP") {
271추가: let output = Command::new(tool)
272추가: .args(["x", "-y"])
273추가: .arg(archive.to_path().unwrap())
274추가: .arg(format!("-o{}", c.0.join("independent").display()))
275추가: .output()
276추가: .unwrap();
277추가: assert!(output.status.success(), "{output:?}");
278추가: assert_eq!(tree(&c.0.join("independent/source")), expected);
279추가: }
280추가: assert!(
281추가: !tree(&c.0.join("source"))
282추가: .keys()
283추가: .any(|name| name.contains(".zipelo-"))
284추가: );
285추가: }
286추가: }
287추가:
230288#[test]
231289fn mixed_unicode_files_and_empty_bitmap_boundaries_round_trip() {
232290 for count in [7, 8, 9] {
@@ -595,6 +653,146 @@ fn source_changes_new_destination_and_cancel_before_publication_are_preserved()
595653 }
596654}
597655
656추가: #[cfg(target_os = "linux")]
657추가: #[test]
658추가: fn internal_destination_still_rejects_real_source_changes_and_cancellation() {
659추가: for parent in ["source", "source/nested"] {
660추가: for operation in [
661추가: "add",
662추가: "foreign-temp",
663추가: "remove",
664추가: "rename",
665추가: "modify",
666추가: "replace-dir",
667추가: "cancel",
668추가: ] {
669추가: let c = Case::new();
670추가: private_dir(&c.0.join("source"));
671추가: private_dir(&c.0.join("source/nested"));
672추가: let directory = c.0.join(parent);
673추가: private_dir(&directory.join("empty"));
674추가: fs::write(directory.join("file"), b"a".repeat(100_000)).unwrap();
675추가: let mut request = c.request(&["source"]);
676추가: if let Action::CreateSevenZip { output_file, .. } = &mut request.action {
677추가: *output_file = NativePath::from_path(&directory.join("result.7z"));
678추가: }
679추가: let marker = c.0.join("marker");
680추가: let release = c.0.join("release");
681추가: let mut command = c.command();
682추가: command
683추가: .env("LD_PRELOAD", shim(&c, "io_fault.c"))
684추가: .env("ZIPELO_TEST_FAULT", "pause")
685추가: .env("ZIPELO_TEST_MARKER", &marker)
686추가: .env("ZIPELO_TEST_RELEASE", &release);
687추가: let mut changed = false;
688추가: let events = c.run_with(&mut command, Message::Start(request), |event| {
689추가: if changed
690추가: || !matches!(
691추가: event,
692추가: Message::Progress {
693추가: stage: Stage::Write,
694추가: total_bytes: Some(_),
695추가: ..
696추가: }
697추가: )
698추가: {
699추가: return Vec::new();
700추가: }
701추가: let until = std::time::Instant::now() + Duration::from_secs(5);
702추가: while !marker.exists() {
703추가: assert!(std::time::Instant::now() < until);
704추가: std::thread::sleep(Duration::from_millis(2));
705추가: }
706추가: match operation {
707추가: "add" => fs::write(directory.join("new-file"), b"user addition").unwrap(),
708추가: "foreign-temp" => {
709추가: fs::write(directory.join(".zipelo-user.tmp"), b"user file").unwrap()
710추가: }
711추가: "remove" => fs::remove_file(directory.join("file")).unwrap(),
712추가: "rename" => {
713추가: fs::rename(directory.join("file"), directory.join("renamed")).unwrap()
714추가: }
715추가: "modify" => fs::write(directory.join("file"), b"user modification").unwrap(),
716추가: "replace-dir" => {
717추가: fs::rename(directory.join("empty"), c.0.join("old-empty")).unwrap();
718추가: private_dir(&directory.join("empty"));
719추가: }
720추가: _ => {}
721추가: }
722추가: changed = true;
723추가: fs::write(&release, b"resume").unwrap();
724추가: if operation == "cancel" {
725추가: vec![Message::Cancel]
726추가: } else {
727추가: Vec::new()
728추가: }
729추가: });
730추가: assert!(changed);
731추가: failure(
732추가: &events,
733추가: if operation == "cancel" {
734추가: ErrorCode::None
735추가: } else {
736추가: ErrorCode::SourceChanged
737추가: },
738추가: );
739추가: assert!(!directory.join("result.7z").exists());
740추가: let expected_temp = if operation == "foreign-temp" { 1 } else { 0 };
741추가: assert_eq!(
742추가: fs::read_dir(&directory)
743추가: .unwrap()
744추가: .filter(|entry| {
745추가: entry
746추가: .as_ref()
747추가: .unwrap()
748추가: .file_name()
749추가: .to_string_lossy()
750추가: .starts_with(".zipelo-")
751추가: })
752추가: .count(),
753추가: expected_temp
754추가: );
755추가: if operation == "foreign-temp" {
756추가: assert_eq!(
757추가: fs::read(directory.join(".zipelo-user.tmp")).unwrap(),
758추가: b"user file"
759추가: );
760추가: }
761추가: if operation == "modify" {
762추가: assert_eq!(
763추가: fs::read(directory.join("file")).unwrap(),
764추가: b"user modification"
765추가: );
766추가: }
767추가: }
768추가: }
769추가: }
770추가:
771추가: #[cfg(target_os = "linux")]
772추가: #[test]
773추가: fn internal_destination_write_failures_clean_only_the_owned_temporary() {
774추가: for fault in ["full", "sync-full"] {
775추가: let c = Case::new();
776추가: private_dir(&c.0.join("source"));
777추가: fs::write(c.0.join("source/file"), b"original").unwrap();
778추가: fs::write(c.0.join("source/.zipelo-user.tmp"), b"keep").unwrap();
779추가: let expected = tree(&c.0.join("source"));
780추가: let mut request = c.request(&["source"]);
781추가: if let Action::CreateSevenZip { output_file, .. } = &mut request.action {
782추가: *output_file = c.path("source/result.7z");
783추가: }
784추가: let mut command = c.command();
785추가: command
786추가: .env("LD_PRELOAD", shim(&c, "io_fault.c"))
787추가: .env("ZIPELO_TEST_FAULT", fault);
788추가: failure(
789추가: &c.run_with(&mut command, Message::Start(request), |_| Vec::new()),
790추가: ErrorCode::DiskFull,
791추가: );
792추가: assert_eq!(tree(&c.0.join("source")), expected);
793추가: }
794추가: }
795추가:
598796#[cfg(target_os = "linux")]
599797#[test]
600798fn encoder_finish_header_write_seek_and_patch_errors_publish_nothing() {