team-ljyzipelo

공개

한도 초과 실패 뒤 다시 시도하면 기본 프로그램이 열리도록 열기 상태를 유지

작성자
호시노 히나타
작성 시각
커밋
1e4beedad5b17981191cdc1ed40a46d7e716535d
부모
a803b68
이 시점의 파일 보기

변경된 파일 2개

+141-1
수정experiments/rust-ui-memory-app/src/archive_screen.rs+25-1
@@ -381,6 +381,7 @@ impl ArchiveApp {
381381
382382 /// 압축파일 안 파일 하나를 임시 폴더에 풀고 기본 프로그램으로 엶.
383383 pub fn open_entry(&mut self, entry_id: u32) -> bool {
384추가: self.release_open();
384385 if !self.model.can_extract() || self.opening.is_some() {
385386 return false;
386387 }
@@ -444,6 +445,18 @@ impl ArchiveApp {
444445 }
445446 }
446447
448추가: /// 한도를 늘려 다시 시도할 수 있는 결과가 화면에 남아 있는 동안은 열기 상태를 유지함.
449추가: fn open_retry_pending(&self) -> bool {
450추가: self.opening.is_some() && !self.dismissed && self.model.can_retry_expanded()
451추가: }
452추가:
453추가: /// 다시 시도를 기다리던 열기를 접고 원래 풀 위치로 되돌림. 다른 작업을 시작하기 전에 씀.
454추가: fn release_open(&mut self) {
455추가: if self.opening.is_some() && !self.model.busy() {
456추가: self.finish_open(false);
457추가: }
458추가: }
459추가:
447460 /// 열기용 풀기가 끝나면 원래 풀 위치를 되돌리고, 성공했으면 기본 프로그램을 실행함.
448461 fn finish_open(&mut self, completed: bool) {
449462 let Some(request) = self.opening.take() else {
@@ -477,6 +490,7 @@ impl ArchiveApp {
477490
478491 /// 압축파일 이름으로 새 폴더를 만들고(같은 이름이 있으면 번호를 붙임) 선택 항목을 풂.
479492 fn extract_to_new_folder(&mut self) -> bool {
493추가: self.release_open();
480494 let Some(archive) = self.model.archive.clone() else {
481495 return false;
482496 };
@@ -610,6 +624,7 @@ impl ArchiveApp {
610624 if self.model.busy() {
611625 return;
612626 }
627추가: self.release_open();
613628 if self
614629 .recovery_warning
615630 .as_ref()
@@ -711,6 +726,7 @@ impl ArchiveApp {
711726 }
712727
713728 pub fn begin_extract(&mut self) -> bool {
729추가: self.release_open();
714730 self.selected_only = !self.model.selected.is_empty();
715731 let selection = if self.selected_only {
716732 Selection::EntryIds(
@@ -951,6 +967,7 @@ impl ArchiveApp {
951967 }
952968 Purpose::Destination | Purpose::Retry => {
953969 // 다른 폴더를 골랐으면 기본 프로그램 열기가 아닌 일반 풀기로 다시 함.
970추가: self.release_open();
954971 self.last_open = None;
955972 self.choose_destination(path);
956973 self.selected_only = !self.model.selected.is_empty();
@@ -1076,7 +1093,10 @@ impl ArchiveApp {
10761093 if self.opening.is_some() {
10771094 // 열기용 폴더는 앱을 닫을 때 지우므로 풀 위치 소유 기록만 정리함.
10781095 self.owned_destination = None;
1079삭제: self.finish_open(completed);
1096추가: // 한도 실패는 늘려서 다시 시도할 수 있으므로 열기 상태를 남김.
1097추가: if completed || !self.open_retry_pending() {
1098추가: self.finish_open(completed);
1099추가: }
10801100 }
10811101 if let Some(path) = self.owned_destination.take() {
10821102 if !self.model.confirmed
@@ -1090,6 +1110,10 @@ impl ArchiveApp {
10901110 }
10911111 }
10921112 }
1113추가: if self.opening.is_some() && !self.model.busy() && !self.open_retry_pending() {
1114추가: // 결과를 닫았거나 다시 시도할 수 없게 되었으면 원래 풀 위치로 되돌림.
1115추가: self.finish_open(false);
1116추가: }
10931117 }
10941118
10951119 pub fn show(&mut self, root: &mut egui::Ui) {
수정tests/rust-app-ui/explorer_selection.rs+116-0
@@ -327,6 +327,122 @@ fn explorer_double_click_opens_files_with_default_app_and_folders_in_place() {
327327 assert!(!root.exists());
328328}
329329
330추가: /// 열기용 풀기가 한도 초과로 실패한 상태까지 진행함. 결과 창을 그리는 문맥도 함께 돌려줌.
331추가: fn double_click_open_hits_limit(s: &mut Explorer) -> egui::Context {
332추가: s.factory.state.borrow_mut().manual = true;
333추가: s.double_click("alpha.txt");
334추가: assert_eq!(s.factory.state.borrow().starts.len(), 2);
335추가: finish_limit(s);
336추가: let ctx = egui::Context::default();
337추가: ctx.set_embed_viewports(false);
338추가: for _ in 0..12 {
339추가: policy_render(&ctx, &mut s.app, vec![]);
340추가: }
341추가: assert!(s.app.model.can_retry_expanded());
342추가: assert!(s.opened.borrow().is_empty());
343추가: ctx
344추가: }
345추가:
346추가: fn finish_limit(s: &mut Explorer) {
347추가: {
348추가: let mut worker = s.factory.state.borrow_mut();
349추가: worker.frame(Event::Accepted { encryption: false });
350추가: worker.frame(Event::Terminal(Terminal {
351추가: outcome: Outcome::Failed,
352추가: error: Some(ErrorCode::Limit),
353추가: publication: Publication::None,
354추가: created_count: 0,
355추가: retained_partial_count: 0,
356추가: durability: Durability::NotApplicable,
357추가: cleanup: Cleanup::Complete,
358추가: }));
359추가: worker.queue.extend([
360추가: HostEvent::StdoutEof,
361추가: HostEvent::StderrEof,
362추가: HostEvent::Exited { success: true },
363추가: ]);
364추가: }
365추가: for _ in 0..30 {
366추가: s.frame(egui::Modifiers::NONE, vec![]);
367추가: }
368추가: }
369추가:
370추가: #[test]
371추가: fn explorer_open_keeps_pending_open_when_limit_retry_succeeds() {
372추가: let scratch = Folder::new();
373추가: let mut s = Explorer::new(&scratch);
374추가: let root = scratch.0.join("sample.zip (Zipelo 임시)");
375추가: let ctx = double_click_open_hits_limit(&mut s);
376추가: policy_click(&ctx, &mut s.app, "한도를 늘려 다시 시도");
377추가: assert!(s.app.model.busy());
378추가: assert!(s.factory.state.borrow().expanded);
379추가: assert!(matches!(
380추가: s.factory.state.borrow().starts.last(),
381추가: Some(Start::Extract { destination, .. }) if destination == &root.join("1")
382추가: ));
383추가: {
384추가: let mut worker = s.factory.state.borrow_mut();
385추가: worker.frame(Event::Accepted { encryption: false });
386추가: worker.frame(Event::Output {
387추가: entry_id: None,
388추가: relative_name: "alpha.txt".into(),
389추가: disposition: Disposition::Created,
390추가: });
391추가: worker.finish(Outcome::Completed, Publication::Complete);
392추가: }
393추가: for _ in 0..30 {
394추가: s.frame(egui::Modifiers::NONE, vec![]);
395추가: }
396추가: // 다시 시도가 성공하면 기본 프로그램이 열림.
397추가: assert_eq!(*s.opened.borrow(), vec![root.join("1").join("alpha.txt")]);
398추가: // 열기가 끝나면 풀 위치는 원래대로 돌아옴.
399추가: s.factory.state.borrow_mut().manual = false;
400추가: assert!(s.app.begin_extract());
401추가: assert!(matches!(
402추가: s.factory.state.borrow().starts.last(),
403추가: Some(Start::Extract { destination, .. }) if !destination.starts_with(&root)
404추가: ));
405추가: }
406추가:
407추가: #[test]
408추가: fn explorer_open_restores_destination_when_limit_result_is_dismissed() {
409추가: let scratch = Folder::new();
410추가: let mut s = Explorer::new(&scratch);
411추가: let root = scratch.0.join("sample.zip (Zipelo 임시)");
412추가: let ctx = double_click_open_hits_limit(&mut s);
413추가: policy_click(&ctx, &mut s.app, "확인");
414추가: for _ in 0..3 {
415추가: policy_render(&ctx, &mut s.app, vec![]);
416추가: }
417추가: assert!(s.opened.borrow().is_empty());
418추가: s.factory.state.borrow_mut().manual = false;
419추가: assert!(s.app.begin_extract());
420추가: let state = s.factory.state.borrow();
421추가: let Some(Start::Extract { destination, .. }) = state.starts.last() else {
422추가: panic!("{:?}", state.starts.last());
423추가: };
424추가: assert_eq!(destination, &scratch.0.join("sample"));
425추가: assert!(!destination.starts_with(&root));
426추가: }
427추가:
428추가: #[test]
429추가: fn explorer_open_restores_destination_when_expanded_retry_fails_again() {
430추가: let scratch = Folder::new();
431추가: let mut s = Explorer::new(&scratch);
432추가: let ctx = double_click_open_hits_limit(&mut s);
433추가: policy_click(&ctx, &mut s.app, "한도를 늘려 다시 시도");
434추가: assert!(s.app.model.busy());
435추가: finish_limit(&mut s);
436추가: assert!(s.opened.borrow().is_empty());
437추가: assert!(!s.app.model.can_retry_expanded());
438추가: s.factory.state.borrow_mut().manual = false;
439추가: assert!(s.app.begin_extract());
440추가: assert!(matches!(
441추가: s.factory.state.borrow().starts.last(),
442추가: Some(Start::Extract { destination, .. }) if destination == &scratch.0.join("sample")
443추가: ));
444추가: }
445추가:
330446#[test]
331447fn explorer_double_click_does_not_open_executables() {
332448 let scratch = Folder::new();