team-ljyzipelo

공개

분할 7z 식별자와 오류 알림 계약을 반영한다

작성자
시로사키 하나
작성 시각
커밋
dbed82233aaf913350d143da0374f2c101ace5ba
부모
86be5c6
이 시점의 파일 보기

변경된 파일 6개

+503-12
수정experiments/rust-archive-worker/README.md+3-3
@@ -176,9 +176,9 @@ Python 표준 bz2, lzma와 tarfile로 독립 생성 및 해제한 결과의 SHA2
176176- backend는 작업자 protocol.rs, wire.rs, runtime 및 디코더, 작업자 시험과 packaging/licenses.py 고지를 맡는다. frontend는 앱 재조립/전송 제어, 화면과 앱 시험, --ui-scenario 및 가이드를 맡는다. 같은 원격 브랜치는 양쪽 결과를 확인하며 순차 갱신하고 공용 타입 변경은 이 계약 합의 후 backend가 반영한다.
177177- 시험은 바이트/치수/픽셀 경계, UTF-8 청크 경계와 BOM, 형식 불일치/APNG/손상, 암호와 solid 예산, malformed/순서/중복/초과 전송, 64개 큐 역압과 디코딩 및 전송 중 취소, 늦은 완료 폐기와 정리 및 원본 해시 보존을 포함한다.
178178
179삭제: ## 분할 7z 계약 초안
179추가: ## 분할 7z 계약
180180
181삭제: 상태: frontend 합의 대기. [PLANS 8.8](../../docs/PLANS.md)의 구현 전 계약 합의를 위한 제안이며 아직 타입, 코덱과 제품 동작에 반영하지 않았다. 기준은 main ecad460이다. 아래 합의 뒤 backend가 공용 타입과 작업자를 반영하고 frontend가 같은 PR에서 화면과 상황별 디버깅 명령을 연결한다.
181추가: 상태: 2026-11-14 frontend 합의 완료. [PLANS 8.8](../../docs/PLANS.md)의 공용 타입과 코덱에 묶음 ListId, MissingVolume 및 VolumeProblem을 반영했다. 조각 탐색과 캡처 및 실제 목록/해제, 앱 수신과 화면 연동은 구현 대기다. 기준은 main ecad460이며 frontend가 같은 PR에서 화면과 상황별 디버깅 명령을 연결한다.
182182
183183### 지원 범위와 조각 탐색
184184
@@ -200,7 +200,7 @@ Python 표준 bz2, lzma와 tarfile로 독립 생성 및 해제한 결과의 SHA2
200200
201201### 묶음 ListId와 바이트 계약
202202
203삭제: 프레임 헤더 버전 1, 본문 1 MiB 상한과 기존 필드 및 태그는 유지한다. 아래 확장은 합의 뒤 공용 타입과 코덱에 추가한다. 구버전 작업자 거부 시 단일 파일 요청이나 일반 해제로 자동 재시도하지 않는다.
203추가: 프레임 헤더 버전 1, 본문 1 MiB 상한과 기존 필드 및 태그는 유지한다. 아래 확장을 공용 타입과 코덱에 추가했다. 구버전 작업자 거부 시 단일 파일 요청이나 일반 해제로 자동 재시도하지 않는다.
204204
205205- SourceObject에 SplitSevenZip { manifest_sha256: [u8; 32] }를 태그 3으로 추가한다. Unix=1과 Windows=2는 유지한다. 분할 7z의 ListId는 catalog_version=2, format=SevenZip, source_object=SplitSevenZip이어야 한다. archive_bytes는 모든 조각의 길이 합계이고 archive_sha256은 번호 순서로 이어진 논리 입력 바이트의 SHA256이다.
206206- 기존 단일 입력은 catalog_version=1과 Unix 또는 Windows 식별자를 그대로 사용한다. 버전, 형식과 SourceObject의 허용 조합을 코덱과 수신기에서 검증하고 그 밖의 조합은 Protocol로 거부한다. 첫 조각 하나의 식별자나 해시를 묶음 식별자로 사용하지 않는다.
수정experiments/rust-archive-worker/src/protocol.rs+51-0
@@ -25,6 +25,22 @@ impl NativePath {
2525 Self::Windows(path.as_os_str().encode_wide().collect())
2626 }
2727 }
28추가: pub fn is_basename(&self) -> bool {
29추가: match self {
30추가: Self::Unix(bytes) => {
31추가: !bytes.is_empty()
32추가: && bytes != b"."
33추가: && bytes != b".."
34추가: && !bytes.iter().any(|byte| matches!(*byte, 0 | b'/' | b'\\'))
35추가: }
36추가: Self::Windows(units) => {
37추가: !units.is_empty()
38추가: && units != &[b'.' as u16]
39추가: && units != &[b'.' as u16, b'.' as u16]
40추가: && !units.iter().any(|unit| matches!(*unit, 0 | 47 | 92 | 58))
41추가: }
42추가: }
43추가: }
2844 pub fn to_path(&self) -> Result<PathBuf, ErrorCode> {
2945 #[cfg(unix)]
3046 if let Self::Unix(bytes) = self {
@@ -150,6 +166,9 @@ pub enum SourceObject {
150166 volume_serial: u64,
151167 file_id: [u8; 16],
152168 },
169추가: SplitSevenZip {
170추가: manifest_sha256: [u8; 32],
171추가: },
153172}
154173#[derive(Clone, Debug, PartialEq, Eq)]
155174pub struct ListId {
@@ -159,6 +178,18 @@ pub struct ListId {
159178 pub archive_bytes: u64,
160179 pub archive_sha256: [u8; 32],
161180}
181추가: impl ListId {
182추가: pub fn valid(&self) -> bool {
183추가: matches!(
184추가: (self.catalog_version, self.format, &self.source_object),
185추가: (
186추가: 1,
187추가: _,
188추가: SourceObject::Unix { .. } | SourceObject::Windows { .. }
189추가: ) | (2, Format::SevenZip, SourceObject::SplitSevenZip { .. })
190추가: )
191추가: }
192추가: }
162193#[derive(Clone, Debug, PartialEq, Eq)]
163194pub enum Selection {
164195 All,
@@ -312,6 +343,22 @@ pub enum ErrorCode {
312343 SourceChanged,
313344 InvalidRequest,
314345 DiskFull,
346추가: MissingVolume,
347추가: }
348추가: #[derive(Clone, Copy, Debug, PartialEq, Eq)]
349추가: pub enum VolumeProblemReason {
350추가: FirstVolumeRequired,
351추가: MissingVolume,
352추가: IncompleteSet,
353추가: }
354추가: impl VolumeProblemReason {
355추가: pub fn terminal_error(self) -> ErrorCode {
356추가: match self {
357추가: Self::FirstVolumeRequired => ErrorCode::InvalidRequest,
358추가: Self::MissingVolume => ErrorCode::MissingVolume,
359추가: Self::IncompleteSet => ErrorCode::Integrity,
360추가: }
361추가: }
315362}
316363#[derive(Clone, Copy, Debug, PartialEq, Eq)]
317364pub enum Publication {
@@ -437,6 +484,10 @@ pub enum Message {
437484 total_bytes: u64,
438485 sha256: [u8; 32],
439486 },
487추가: VolumeProblem {
488추가: reason: VolumeProblemReason,
489추가: volume: NativePath,
490추가: },
440491 Terminal(Terminal),
441492 CancelAck {
442493 request_sequence: u64,
수정experiments/rust-archive-worker/src/space.rs+1-0
@@ -7,6 +7,7 @@ pub(crate) fn volume(file: &File) -> Result<u64> {
77 Ok(match crate::filesystem::object(file)? {
88 SourceObject::Unix { device, .. } => device,
99 SourceObject::Windows { volume_serial, .. } => volume_serial,
10추가: SourceObject::SplitSevenZip { .. } => return Err(ErrorCode::Protocol),
1011 })
1112}
1213
수정experiments/rust-archive-worker/src/wire.rs+50-8
@@ -144,7 +144,8 @@ enumeration!(EntryKind{File=0,Directory=1,Link=2,Other=3});
144144enumeration!(Stage{Scan=0,Read=1,Decode=2,Write=3,Verify=4,Commit=5});
145145enumeration!(Disposition{Created=0,PartialRetained=1,Removed=2,CommitUncertain=3});
146146enumeration!(Outcome{Completed=0,Failed=1,Cancelled=2});
147삭제: enumeration!(ErrorCode{None=0,Integrity=1,UnsupportedFormat=2,UnsupportedFeature=3,WrongPassword=4,UnsafePath=5,Conflict=6,Limit=7,Io=8,Protocol=9,Internal=10,SourceChanged=11,InvalidRequest=12,DiskFull=13});
147추가: enumeration!(ErrorCode{None=0,Integrity=1,UnsupportedFormat=2,UnsupportedFeature=3,WrongPassword=4,UnsafePath=5,Conflict=6,Limit=7,Io=8,Protocol=9,Internal=10,SourceChanged=11,InvalidRequest=12,DiskFull=13,MissingVolume=14});
148추가: enumeration!(VolumeProblemReason{FirstVolumeRequired=0,MissingVolume=1,IncompleteSet=2});
148149enumeration!(Publication{None=0,Partial=1,Complete=2,Uncertain=3});
149150enumeration!(Durability{NotApplicable=0,Synced=1,Unconfirmed=2,Failed=3});
150151enumeration!(Cleanup{Complete=0,Failed=1,Unconfirmed=2});
@@ -160,13 +161,31 @@ structure!(Limits {
160161 output,
161162 entries
162163});
163삭제: structure!(ListId {
164삭제: catalog_version,
165삭제: format,
166삭제: source_object,
167삭제: archive_bytes,
168삭제: archive_sha256
169삭제: });
164추가: impl Wire for ListId {
165추가: fn enc(&self, e: &mut Encoder) -> io::Result<()> {
166추가: if !self.valid() {
167추가: return Err(invalid());
168추가: }
169추가: self.catalog_version.enc(e)?;
170추가: self.format.enc(e)?;
171추가: self.source_object.enc(e)?;
172추가: self.archive_bytes.enc(e)?;
173추가: self.archive_sha256.enc(e)
174추가: }
175추가: fn dec(d: &mut Decoder<'_>) -> io::Result<Self> {
176추가: let id = Self {
177추가: catalog_version: Wire::dec(d)?,
178추가: format: Wire::dec(d)?,
179추가: source_object: Wire::dec(d)?,
180추가: archive_bytes: Wire::dec(d)?,
181추가: archive_sha256: Wire::dec(d)?,
182추가: };
183추가: if !id.valid() {
184추가: return Err(invalid());
185추가: }
186추가: Ok(id)
187추가: }
188추가: }
170189impl Wire for PreviewInfo {
171190 fn enc(&self, e: &mut Encoder) -> io::Result<()> {
172191 if !self.valid() {
@@ -268,6 +287,10 @@ impl Wire for SourceObject {
268287 volume_serial.enc(e)?;
269288 file_id.enc(e)
270289 }
290추가: Self::SplitSevenZip { manifest_sha256 } => {
291추가: 3u8.enc(e)?;
292추가: manifest_sha256.enc(e)
293추가: }
271294 }
272295 }
273296 fn dec(d: &mut Decoder<'_>) -> io::Result<Self> {
@@ -280,6 +303,9 @@ impl Wire for SourceObject {
280303 volume_serial: Wire::dec(d)?,
281304 file_id: Wire::dec(d)?,
282305 }),
306추가: 3 => Ok(Self::SplitSevenZip {
307추가: manifest_sha256: Wire::dec(d)?,
308추가: }),
283309 _ => Err(invalid()),
284310 }
285311 }
@@ -537,6 +563,14 @@ impl Message {
537563 sha256.enc(&mut e)?;
538564 113
539565 }
566추가: Self::VolumeProblem { reason, volume } => {
567추가: if !volume.is_basename() {
568추가: return Err(invalid());
569추가: }
570추가: reason.enc(&mut e)?;
571추가: volume.enc(&mut e)?;
572추가: 114
573추가: }
540574 Self::Terminal(v) => {
541575 if v.detail.len() > 4096 {
542576 return Err(invalid());
@@ -702,6 +736,14 @@ impl Message {
702736 sha256: Wire::dec(&mut d)?,
703737 }
704738 }
739추가: 114 => {
740추가: let reason = Wire::dec(&mut d)?;
741추가: let volume = NativePath::dec(&mut d)?;
742추가: if !volume.is_basename() {
743추가: return Err(invalid());
744추가: }
745추가: Self::VolumeProblem { reason, volume }
746추가: }
705747 106 => {
706748 let t = Terminal::dec(&mut d)?;
707749 if t.detail.len() > 4096 {
수정tests/rust-archive-worker/main.rs+3-1
@@ -1601,7 +1601,7 @@ fn disk_full_error_tag_preserves_previous_tags_and_rejects_unknown() {
16011601 assert_eq!(bytes[33], tag as u8);
16021602 let decoded = Reader::new(bytes.as_slice()).read().unwrap().unwrap().2;
16031603 assert_eq!(terminal(&[decoded]).error, error);
1604삭제: bytes[33] = 14;
1604추가: bytes[33] = 15;
16051605 assert!(Reader::new(bytes.as_slice()).read().is_err());
16061606 }
16071607}
@@ -1614,6 +1614,8 @@ mod conflict_wire;
16141614
16151615mod preview_wire;
16161616
1617추가: mod split_volume_wire;
1618추가:
16171619mod preview_runtime;
16181620
16191621mod conflicts;
추가tests/rust-archive-worker/split_volume_wire.rs+395-0
@@ -0,0 +1,395 @@
1추가: use super::*;
2추가:
3추가: fn frame(kind: u16, body: &[u8]) -> Vec<u8> {
4추가: let mut bytes = b"ZAW1".to_vec();
5추가: bytes.extend(1u16.to_le_bytes());
6추가: bytes.extend(kind.to_le_bytes());
7추가: bytes.extend((body.len() as u32).to_le_bytes());
8추가: bytes.extend([0; 4]);
9추가: bytes.extend(17u64.to_le_bytes());
10추가: bytes.extend(0u64.to_le_bytes());
11추가: bytes.extend(body);
12추가: bytes
13추가: }
14추가:
15추가: fn encoded(message: &Message) -> Vec<u8> {
16추가: let mut bytes = Vec::new();
17추가: Writer::new(&mut bytes, 17).send(message).unwrap();
18추가: bytes
19추가: }
20추가:
21추가: fn decoded(bytes: &[u8]) -> Message {
22추가: let mut reader = Reader::new(bytes);
23추가: let (job, sequence, message) = reader.read().unwrap().unwrap();
24추가: assert_eq!((job, sequence), (17, 0));
25추가: assert!(reader.read().unwrap().is_none());
26추가: message
27추가: }
28추가:
29추가: fn reject_encode(message: &Message) {
30추가: let mut bytes = Vec::new();
31추가: assert_eq!(
32추가: Writer::new(&mut bytes, 17)
33추가: .send(message)
34추가: .unwrap_err()
35추가: .kind(),
36추가: std::io::ErrorKind::InvalidData
37추가: );
38추가: assert!(bytes.is_empty());
39추가: }
40추가:
41추가: fn reject_decode(bytes: &[u8]) {
42추가: assert!(Reader::new(bytes).read().is_err());
43추가: }
44추가:
45추가: fn identity() -> ListId {
46추가: ListId {
47추가: catalog_version: 2,
48추가: format: Format::SevenZip,
49추가: source_object: SourceObject::SplitSevenZip {
50추가: manifest_sha256: [31; 32],
51추가: },
52추가: archive_bytes: 0x0102_0304_0506_0708,
53추가: archive_sha256: [37; 32],
54추가: }
55추가: }
56추가:
57추가: fn identity_bytes(id: &ListId) -> Vec<u8> {
58추가: let mut bytes = id.catalog_version.to_le_bytes().to_vec();
59추가: bytes.push(match id.format {
60추가: Format::Zip => 0,
61추가: Format::Tar => 1,
62추가: Format::Gzip => 2,
63추가: Format::TarGzip => 3,
64추가: Format::SevenZip => 4,
65추가: });
66추가: match id.source_object {
67추가: SourceObject::Unix { device, inode } => {
68추가: bytes.push(1);
69추가: bytes.extend(device.to_le_bytes());
70추가: bytes.extend(inode.to_le_bytes());
71추가: }
72추가: SourceObject::Windows {
73추가: volume_serial,
74추가: file_id,
75추가: } => {
76추가: bytes.push(2);
77추가: bytes.extend(volume_serial.to_le_bytes());
78추가: bytes.extend(file_id);
79추가: }
80추가: SourceObject::SplitSevenZip { manifest_sha256 } => {
81추가: bytes.push(3);
82추가: bytes.extend(manifest_sha256);
83추가: }
84추가: }
85추가: bytes.extend(id.archive_bytes.to_le_bytes());
86추가: bytes.extend(id.archive_sha256);
87추가: bytes
88추가: }
89추가:
90추가: fn list_end(id: &ListId) -> Vec<u8> {
91추가: let mut body = 7u32.to_le_bytes().to_vec();
92추가: body.extend(identity_bytes(id));
93추가: frame(102, &body)
94추가: }
95추가:
96추가: #[test]
97추가: fn split_list_identity_keeps_header_and_exact_digest_field_order() {
98추가: let id = identity();
99추가: let raw = list_end(&id);
100추가: assert_eq!(raw.len(), 32 + 4 + 2 + 1 + 1 + 32 + 8 + 32);
101추가: assert_eq!(&raw[36..40], &[2, 0, 4, 3]);
102추가: assert_eq!(&raw[40..72], &[31; 32]);
103추가: assert_eq!(&raw[72..80], &id.archive_bytes.to_le_bytes());
104추가: assert_eq!(&raw[80..112], &[37; 32]);
105추가: assert_eq!(
106추가: encoded(&Message::ListEnd {
107추가: entry_count: 7,
108추가: list_id: id.clone()
109추가: }),
110추가: raw
111추가: );
112추가: match decoded(&raw) {
113추가: Message::ListEnd {
114추가: entry_count,
115추가: list_id,
116추가: } => {
117추가: assert_eq!(entry_count, 7);
118추가: assert_eq!(list_id, id);
119추가: }
120추가: other => panic!("{other:?}"),
121추가: }
122추가: }
123추가:
124추가: #[test]
125추가: fn split_identity_is_preserved_in_all_existing_extract_requests() {
126추가: for windows in [false, true] {
127추가: for selection in [Selection::All, Selection::EntryIds(vec![2, 5])] {
128추가: let start = Start {
129추가: action: Action::Extract {
130추가: archive: if windows {
131추가: NativePath::Windows("C:\\set.7z.001".encode_utf16().collect())
132추가: } else {
133추가: NativePath::Unix(b"/set.7z.001".to_vec())
134추가: },
135추가: destination: if windows {
136추가: NativePath::Windows("C:\\output".encode_utf16().collect())
137추가: } else {
138추가: NativePath::Unix(b"/output".to_vec())
139추가: },
140추가: selection,
141추가: list_id: Some(identity()),
142추가: gzip_output_name: None,
143추가: },
144추가: limits: Limits::default(),
145추가: };
146추가: for kind in [1u16, 4, 6] {
147추가: let message = match kind {
148추가: 1 => Message::Start(start.clone()),
149추가: 4 => Message::StartInteractive(start.clone()),
150추가: 6 => Message::StartGuarded(GuardedStart {
151추가: start: start.clone(),
152추가: ceiling: start.limits,
153추가: interactive: true,
154추가: }),
155추가: _ => unreachable!(),
156추가: };
157추가: let bytes = encoded(&message);
158추가: assert_eq!(&bytes[6..8], &kind.to_le_bytes());
159추가: let actual = match decoded(&bytes) {
160추가: Message::Start(value) | Message::StartInteractive(value) => value,
161추가: Message::StartGuarded(value) => value.start,
162추가: other => panic!("{other:?}"),
163추가: };
164추가: assert_eq!(actual, start);
165추가: }
166추가: }
167추가: }
168추가: }
169추가:
170추가: #[test]
171추가: fn list_identity_accepts_only_agreed_version_format_and_object_combinations() {
172추가: let objects = [
173추가: SourceObject::Unix {
174추가: device: 11,
175추가: inode: 13,
176추가: },
177추가: SourceObject::Windows {
178추가: volume_serial: 17,
179추가: file_id: [19; 16],
180추가: },
181추가: SourceObject::SplitSevenZip {
182추가: manifest_sha256: [23; 32],
183추가: },
184추가: ];
185추가: for catalog_version in [0, 1, 2, 3, u16::MAX] {
186추가: for format in [
187추가: Format::Zip,
188추가: Format::Tar,
189추가: Format::Gzip,
190추가: Format::TarGzip,
191추가: Format::SevenZip,
192추가: ] {
193추가: for source_object in &objects {
194추가: let id = ListId {
195추가: catalog_version,
196추가: format,
197추가: source_object: source_object.clone(),
198추가: ..identity()
199추가: };
200추가: let split = matches!(source_object, SourceObject::SplitSevenZip { .. });
201추가: let valid = (catalog_version == 1 && !split)
202추가: || (catalog_version == 2 && format == Format::SevenZip && split);
203추가: assert_eq!(id.valid(), valid, "{id:?}");
204추가: let message = Message::ListEnd {
205추가: entry_count: 7,
206추가: list_id: id.clone(),
207추가: };
208추가: let raw = list_end(&id);
209추가: if valid {
210추가: assert_eq!(encoded(&message), raw);
211추가: assert!(
212추가: matches!(decoded(&raw), Message::ListEnd { list_id, .. } if list_id == id)
213추가: );
214추가: } else {
215추가: reject_encode(&message);
216추가: reject_decode(&raw);
217추가: }
218추가: }
219추가: }
220추가: }
221추가: }
222추가:
223추가: #[test]
224추가: fn split_identity_rejects_unknown_tags_truncation_and_trailing_bytes() {
225추가: let raw = list_end(&identity());
226추가: for (offset, value) in [(38, 5), (39, 0), (39, 4)] {
227추가: let mut invalid = raw.clone();
228추가: invalid[offset] = value;
229추가: reject_decode(&invalid);
230추가: }
231추가: for length in 32..raw.len() {
232추가: reject_decode(&frame(102, &raw[32..length]));
233추가: }
234추가: let mut body = raw[32..].to_vec();
235추가: body.push(0);
236추가: reject_decode(&frame(102, &body));
237추가: }
238추가:
239추가: fn volume_body(reason: u8, path: &NativePath) -> Vec<u8> {
240추가: let mut body = vec![reason];
241추가: match path {
242추가: NativePath::Unix(bytes) => {
243추가: body.push(1);
244추가: body.extend((bytes.len() as u32).to_le_bytes());
245추가: body.extend(bytes);
246추가: }
247추가: NativePath::Windows(units) => {
248추가: body.push(2);
249추가: body.extend((units.len() as u32).to_le_bytes());
250추가: for unit in units {
251추가: body.extend(unit.to_le_bytes());
252추가: }
253추가: }
254추가: }
255추가: body
256추가: }
257추가:
258추가: #[test]
259추가: fn volume_problem_preserves_native_names_reason_tags_and_error_mapping() {
260추가: for (tag, reason, error) in [
261추가: (
262추가: 0,
263추가: VolumeProblemReason::FirstVolumeRequired,
264추가: ErrorCode::InvalidRequest,
265추가: ),
266추가: (
267추가: 1,
268추가: VolumeProblemReason::MissingVolume,
269추가: ErrorCode::MissingVolume,
270추가: ),
271추가: (2, VolumeProblemReason::IncompleteSet, ErrorCode::Integrity),
272추가: ] {
273추가: assert_eq!(reason.terminal_error(), error);
274추가: for volume in [
275추가: NativePath::Unix(b"set.7z.001".to_vec()),
276추가: NativePath::Unix(b"\xff\x01.7z.009".to_vec()),
277추가: NativePath::Windows("한글.7z.010".encode_utf16().collect()),
278추가: NativePath::Windows(vec![0xd800, 46, 55, 122, 46, 48, 48, 49]),
279추가: ] {
280추가: assert!(volume.is_basename());
281추가: let raw = frame(114, &volume_body(tag, &volume));
282추가: assert_eq!(
283추가: encoded(&Message::VolumeProblem {
284추가: reason,
285추가: volume: volume.clone()
286추가: }),
287추가: raw
288추가: );
289추가: match decoded(&raw) {
290추가: Message::VolumeProblem {
291추가: reason: actual_reason,
292추가: volume: actual_volume,
293추가: } => {
294추가: assert_eq!(actual_reason, reason);
295추가: assert_eq!(actual_volume, volume);
296추가: }
297추가: other => panic!("{other:?}"),
298추가: }
299추가: }
300추가: }
301추가: }
302추가:
303추가: #[test]
304추가: fn volume_problem_rejects_paths_nul_empty_and_parent_names_in_both_directions() {
305추가: for name in [
306추가: "",
307추가: ".",
308추가: "..",
309추가: "/set.7z.001",
310추가: "../set.7z.001",
311추가: "a/set.7z.001",
312추가: "a\\set.7z.001",
313추가: "set\0.7z.001",
314추가: ] {
315추가: for volume in [
316추가: NativePath::Unix(name.as_bytes().to_vec()),
317추가: NativePath::Windows(name.encode_utf16().collect()),
318추가: ] {
319추가: assert!(!volume.is_basename(), "{volume:?}");
320추가: reject_encode(&Message::VolumeProblem {
321추가: reason: VolumeProblemReason::MissingVolume,
322추가: volume: volume.clone(),
323추가: });
324추가: reject_decode(&frame(114, &volume_body(1, &volume)));
325추가: }
326추가: }
327추가: for name in ["C:set.7z.001", "C:\\set.7z.001", "\\\\server\\set.7z.001"] {
328추가: let volume = NativePath::Windows(name.encode_utf16().collect());
329추가: assert!(!volume.is_basename());
330추가: reject_encode(&Message::VolumeProblem {
331추가: reason: VolumeProblemReason::MissingVolume,
332추가: volume: volume.clone(),
333추가: });
334추가: reject_decode(&frame(114, &volume_body(1, &volume)));
335추가: }
336추가: }
337추가:
338추가: #[test]
339추가: fn volume_problem_keeps_native_path_limits_and_strict_body_lengths() {
340추가: for count in [32_768, 32_769] {
341추가: for volume in [
342추가: NativePath::Unix(vec![b'a'; count]),
343추가: NativePath::Windows(vec![b'a' as u16; count]),
344추가: ] {
345추가: let message = Message::VolumeProblem {
346추가: reason: VolumeProblemReason::IncompleteSet,
347추가: volume: volume.clone(),
348추가: };
349추가: let raw = frame(114, &volume_body(2, &volume));
350추가: if count == 32_768 {
351추가: assert_eq!(encoded(&message), raw);
352추가: assert!(matches!(decoded(&raw), Message::VolumeProblem { .. }));
353추가: assert!(raw.len() - 32 < zipelo_archive_worker::wire::MAX_BODY);
354추가: } else {
355추가: reject_encode(&message);
356추가: reject_decode(&raw);
357추가: }
358추가: }
359추가: }
360추가: let body = volume_body(0, &NativePath::Unix(b"set.7z.001".to_vec()));
361추가: for length in 0..body.len() {
362추가: reject_decode(&frame(114, &body[..length]));
363추가: }
364추가: for (offset, value) in [(0, 3), (1, 0), (1, 3)] {
365추가: let mut invalid = body.clone();
366추가: invalid[offset] = value;
367추가: reject_decode(&frame(114, &invalid));
368추가: }
369추가: let mut trailing = body.clone();
370추가: trailing.push(0);
371추가: reject_decode(&frame(114, &trailing));
372추가: let mut huge = body;
373추가: huge[2..6].copy_from_slice(&u32::MAX.to_le_bytes());
374추가: reject_decode(&frame(114, &huge));
375추가: }
376추가:
377추가: #[test]
378추가: fn missing_volume_terminal_uses_tag_14_and_rejects_unknown_tag_15() {
379추가: let message = Message::Terminal(Terminal {
380추가: outcome: Outcome::Failed,
381추가: error: ErrorCode::MissingVolume,
382추가: publication: Publication::None,
383추가: created_count: 0,
384추가: retained_partial_count: 0,
385추가: durability: Durability::NotApplicable,
386추가: cleanup: Cleanup::Complete,
387추가: detail: String::new(),
388추가: });
389추가: let mut bytes = encoded(&message);
390추가: assert_eq!(&bytes[6..8], &106u16.to_le_bytes());
391추가: assert_eq!(bytes[33], 14);
392추가: assert!(matches!(decoded(&bytes), Message::Terminal(t) if t.error == ErrorCode::MissingVolume));
393추가: bytes[33] = 15;
394추가: reject_decode(&bytes);
395추가: }