team-ljyzipelo

공개

미리보기 승인에 전체 목록 크기를 반영한다

작성자
호시노 히나타
작성 시각
커밋
f951b6075719e585f2751eaee32f506539240a02
부모
6a349a7
이 시점의 파일 보기

변경된 파일 5개

+131-5
수정docs/ui-scenario-guide.md+1-0
@@ -150,6 +150,7 @@ Ubuntu 제거 안내는 패키지 관리자 터미널 출력입니다. 이전
150150
151151### 파일 미리보기
152152
153추가: - preview-catalog-bytes-approval: 전체 목록 크기가 16 GiB를 넘는 압축파일에서 7바이트 텍스트를 미리볼 때 새 승인을 요청. 미리보기 고유 상한은 유지.
153154- preview-catalog-approval: 10,001개 목록에서 파일 하나를 미리볼 때 목록 전체 처리 예산의 새 승인을 요청. 텍스트 1 MiB와 이미지 8 MiB 고유 상한은 유지.
154155- preview-loading: 미리보기 로딩 중 [취소] 또는 Esc로 닫기. 닫힌 결과는 늦게 도착해도 표시하지 않음.
155156- preview-text: UTF-8 텍스트의 읽기 전용 표시와 스크롤.
수정experiments/rust-ui-memory-app/src/archive_ui.rs+2-3
@@ -500,13 +500,12 @@ impl Model {
500500 .then(|| u32::try_from(sources.len()).ok())
501501 .flatten();
502502 }
503삭제: Start::Preview { entry_id, .. } => {
503추가: Start::Preview { .. } => {
504504 usage.estimated_entries = u32::try_from(self.entries.len()).ok();
505505 usage.estimated_bytes = self
506506 .entries
507507 .iter()
508삭제: .find(|e| e.id == *entry_id)
509삭제: .and_then(|e| e.bytes);
508추가: .try_fold(0u64, |sum, e| sum.checked_add(e.bytes?));
510509 }
511510 Start::List { .. } => {}
512511 }
수정tests/rust-app-real-worker/preview_catalog.rs+115-0
@@ -108,3 +108,118 @@ fn preview_catalog_denial_does_not_show_data() {
108108fn preview_catalog_approval_does_not_raise_image_size_limit() {
109109 preview_catalog(10_001, 8 * 1024 * 1024 + 1, true, true);
110110}
111추가:
112추가: fn preview_catalog_bytes(total: u64, allow: bool) {
113추가: let scratch = Scratch::new();
114추가: let archive = scratch.path("catalog-bytes.zip");
115추가: // 선택하지 않은 큰 항목은 해제하지 않고 ZIP64 목록 예산만 검증함.
116추가: let generated = std::process::Command::new("python3")
117추가: .arg("-c")
118추가: .arg(
119추가: r#"
120추가: import struct, sys, zlib
121추가: central = []
122추가: with open(sys.argv[1], 'wb') as f:
123추가: for name, size, compressed, payload in [
124추가: (b'small.txt', 7, 7, b'preview'),
125추가: (b'large.bin', int(sys.argv[2]) - 7, 75 * 1024 * 1024, None),
126추가: ]:
127추가: offset = f.tell()
128추가: crc = zlib.crc32(payload) if payload else 0
129추가: method = 0 if payload else 8
130추가: extra = struct.pack('<HHQQ', 1, 16, size, compressed)
131추가: f.write(struct.pack('<IHHHHHIIIHH', 0x04034b50, 45, 0, method, 0, 0,
132추가: crc, 0xffffffff, 0xffffffff, len(name), len(extra)))
133추가: f.write(name + extra)
134추가: if payload:
135추가: f.write(payload)
136추가: else:
137추가: f.seek(compressed, 1)
138추가: central.append(struct.pack('<IHHHHHHIIIHHHHHII', 0x02014b50, 45, 45,
139추가: 0, method, 0, 0, crc, 0xffffffff, 0xffffffff,
140추가: len(name), len(extra), 0, 0, 0, 0, offset)
141추가: + name + extra)
142추가: offset = f.tell()
143추가: data = b''.join(central)
144추가: f.write(data)
145추가: f.write(struct.pack('<IHHHHIIH', 0x06054b50, 0, 0, 2, 2, len(data), offset, 0))
146추가: "#,
147추가: )
148추가: .arg(&archive)
149추가: .arg(total.to_string())
150추가: .output()
151추가: .unwrap();
152추가: assert!(generated.status.success(), "{:?}", generated);
153추가: let mut factory = ProcessFactory::new(binary("zipelo-archive-worker"));
154추가: let mut model = Model::default();
155추가: assert!(model.begin(Start::List { archive }, &mut factory));
156추가: wait(&mut model);
157추가: if total > Limits::default().output {
158추가: assert_eq!(
159추가: model.terminal.as_ref().unwrap().error,
160추가: Some(ErrorCode::Limit)
161추가: );
162추가: assert!(model.retry_expanded(&mut factory));
163추가: finish_catalog_bytes(&mut model, true, ActionKind::List);
164추가: }
165추가: completed(&model);
166추가: assert_eq!(model.entries.len(), 2);
167추가: assert_eq!(
168추가: model.entries.iter().map(|e| e.bytes.unwrap()).sum::<u64>(),
169추가: total
170추가: );
171추가: let id = model
172추가: .entries
173추가: .iter()
174추가: .find(|e| e.name == "small.txt")
175추가: .unwrap()
176추가: .id;
177추가: model.selected.insert(id);
178추가: assert!(model.begin_preview(&mut factory));
179추가: assert_eq!(model.estimated_usage().estimated_bytes, Some(total));
180추가: let questions = finish_catalog_bytes(&mut model, allow, ActionKind::Preview);
181추가: assert_eq!(questions, usize::from(total > Limits::default().output));
182추가: if allow {
183추가: completed(&model);
184추가: assert_eq!(model.preview.as_ref().unwrap().data, b"preview");
185추가: } else {
186추가: assert!(model.preview.is_none());
187추가: assert_ne!(model.terminal.as_ref().unwrap().outcome, Outcome::Completed);
188추가: }
189추가: assert!(model.outputs.is_empty());
190추가: assert_eq!(model.selected, [id].into_iter().collect());
191추가: }
192추가:
193추가: fn finish_catalog_bytes(model: &mut Model, allow: bool, action: ActionKind) -> usize {
194추가: let deadline = Instant::now() + Duration::from_secs(30);
195추가: let mut questions = 0;
196추가: while model.busy() {
197추가: model.poll();
198추가: if let Some(question) = model.resource.clone() {
199추가: assert!(question.scope.output);
200추가: assert!(!question.scope.ratio);
201추가: assert_eq!(question.action, action);
202추가: assert!(model.resource_reply(model.job_id().unwrap(), question.id, allow));
203추가: questions += 1;
204추가: }
205추가: assert!(Instant::now() < deadline, "{:?}", model.error);
206추가: std::thread::sleep(Duration::from_millis(1));
207추가: }
208추가: assert!(model.error.is_none(), "{:?}", model.error);
209추가: questions
210추가: }
211추가:
212추가: #[test]
213추가: fn preview_catalog_at_default_byte_limit_needs_no_approval() {
214추가: preview_catalog_bytes(Limits::default().output, true);
215추가: }
216추가:
217추가: #[test]
218추가: fn preview_catalog_over_default_byte_limit_requires_new_approval() {
219추가: preview_catalog_bytes(Limits::default().output + 1, true);
220추가: }
221추가:
222추가: #[test]
223추가: fn preview_catalog_byte_approval_denial_does_not_show_data() {
224추가: preview_catalog_bytes(Limits::default().output + 1, false);
225추가: }
수정tests/rust-app-ui/scenario_tests.rs+3-1
@@ -97,7 +97,9 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
9797 assert!(app.model.input_error.is_none(), "{}", scenario.name);
9898 let expected = match scenario.name {
9999 "preview-implicit-folder" => "자료",
100삭제: "preview-catalog-approval" => "큰 작업을 허용할까요?",
100추가: "preview-catalog-approval" | "preview-catalog-bytes-approval" => {
101추가: "큰 작업을 허용할까요?"
102추가: }
101103 "preview-loading" => "미리보기를 불러오는 중입니다",
102104 "preview-text" => "여행 준비 목록",
103105 "preview-image" => "미리보기",
수정tests/rust-app-ui/scenarios.rs+10-1
@@ -21,6 +21,7 @@ macro_rules! catalog {
2121}
2222
2323catalog! {
24추가: "preview-catalog-bytes-approval" => "16 GiB를 넘는 전체 목록의 미리보기 승인",
2425 "preview-catalog-approval" => "미리보기의 전체 목록 처리 예산 승인",
2526 "preview-loading" => "미리보기 로딩과 취소",
2627 "preview-text" => "읽기 전용 텍스트 미리보기",
@@ -289,8 +290,16 @@ impl Scenario {
289290 })
290291 .collect();
291292 }
293추가: if self.name == "preview-catalog-bytes-approval" {
294추가: app.model.entries.truncate(2);
295추가: app.model.entries[0].bytes = Some(16 * 1024 * 1024 * 1024);
296추가: app.model.entries[1].bytes = Some(7);
297추가: }
292298 app.begin_preview(&egui::Context::default());
293삭제: if self.name == "preview-catalog-approval" {
299추가: if matches!(
300추가: self.name,
301추가: "preview-catalog-approval" | "preview-catalog-bytes-approval"
302추가: ) {
294303 let mut state = state.borrow_mut();
295304 state.frame(Event::Accepted { encryption: false });
296305 state.frame(Event::ResourceRequired(ResourceChallenge {