team-ljyzipelo

공개

Merge pull request #151 from Team-LJY/fix/pr144-limit-open-retry

한도 초과 실패 뒤 다시 시도하면 파일 열기를 이어서 실행
작성자
LeeJunyoung
작성 시각
커밋
97f490ff28235c5b4b879119dc538f9ea569e1b7
이 시점의 파일 보기

변경된 파일 2개

+195-1
수정experiments/rust-ui-memory-app/src/archive_screen.rs+27-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(
@@ -832,6 +848,8 @@ impl ArchiveApp {
832848 aes256: self.aes256,
833849 }
834850 };
851추가: // 한도 초과 뒤 보류된 열기는 만들기와 무관하므로 시작 전에 접음.
852추가: self.release_open();
835853 if self.start(request) {
836854 self.create = false;
837855 self.create_win = WorkWindow::default();
@@ -951,6 +969,7 @@ impl ArchiveApp {
951969 }
952970 Purpose::Destination | Purpose::Retry => {
953971 // 다른 폴더를 골랐으면 기본 프로그램 열기가 아닌 일반 풀기로 다시 함.
972추가: self.release_open();
954973 self.last_open = None;
955974 self.choose_destination(path);
956975 self.selected_only = !self.model.selected.is_empty();
@@ -1076,7 +1095,10 @@ impl ArchiveApp {
10761095 if self.opening.is_some() {
10771096 // 열기용 폴더는 앱을 닫을 때 지우므로 풀 위치 소유 기록만 정리함.
10781097 self.owned_destination = None;
1079삭제: self.finish_open(completed);
1098추가: // 한도 실패는 늘려서 다시 시도할 수 있으므로 열기 상태를 남김.
1099추가: if completed || !self.open_retry_pending() {
1100추가: self.finish_open(completed);
1101추가: }
10801102 }
10811103 if let Some(path) = self.owned_destination.take() {
10821104 if !self.model.confirmed
@@ -1090,6 +1112,10 @@ impl ArchiveApp {
10901112 }
10911113 }
10921114 }
1115추가: if self.opening.is_some() && !self.model.busy() && !self.open_retry_pending() {
1116추가: // 결과를 닫았거나 다시 시도할 수 없게 되었으면 원래 풀 위치로 되돌림.
1117추가: self.finish_open(false);
1118추가: }
10931119 }
10941120
10951121 pub fn show(&mut self, root: &mut egui::Ui) {
수정tests/rust-app-ui/explorer_selection.rs+168-0
@@ -327,6 +327,174 @@ 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추가:
446추가: #[test]
447추가: fn explorer_open_pending_after_limit_is_dropped_when_zip_creation_starts() {
448추가: let scratch = Folder::new();
449추가: let mut s = Explorer::new(&scratch);
450추가: let root = scratch.0.join("sample.zip (Zipelo 임시)");
451추가: let _limit_ctx = double_click_open_hits_limit(&mut s);
452추가: // 한도 초과 결과를 닫지 않고 폴더를 끌어 놓아 ZIP 만들기를 시작함.
453추가: let folder = scratch.0.join("photos");
454추가: std::fs::create_dir_all(&folder).unwrap();
455추가: std::fs::write(folder.join("a.txt"), b"abc").unwrap();
456추가: s.app.add_sources(vec![folder]);
457추가: let ctx = egui::Context::default();
458추가: policy_click(&ctx, &mut s.app, "압축하기");
459추가: assert!(s.app.model.busy());
460추가: assert!(matches!(
461추가: s.factory.state.borrow().starts.last(),
462추가: Some(Start::CreateZip { .. })
463추가: ));
464추가: {
465추가: let mut worker = s.factory.state.borrow_mut();
466추가: worker.frame(Event::Accepted { encryption: false });
467추가: worker.frame(Event::Output {
468추가: entry_id: None,
469추가: relative_name: "photos.zip".into(),
470추가: disposition: Disposition::Created,
471추가: });
472추가: worker.finish(Outcome::Completed, Publication::Complete);
473추가: }
474추가: for _ in 0..30 {
475추가: s.frame(egui::Modifiers::NONE, vec![]);
476추가: }
477추가: // 만들기가 끝나도 이전 열기가 적용되지 않아 오류가 뜨지 않음.
478추가: for _ in 0..3 {
479추가: policy_render(&ctx, &mut s.app, vec![]);
480추가: }
481추가: let shown = policy_render(&ctx, &mut s.app, vec![]);
482추가: assert!(
483추가: !shown.iter().any(|(text, _)| text.contains("열지 못했습니다")),
484추가: "{shown:?}"
485추가: );
486추가: assert!(s.opened.borrow().is_empty());
487추가: // 풀 위치도 원래대로 돌아옴.
488추가: s.factory.state.borrow_mut().manual = false;
489추가: assert!(s.app.begin_extract());
490추가: let state = s.factory.state.borrow();
491추가: let Some(Start::Extract { destination, .. }) = state.starts.last() else {
492추가: panic!("{:?}", state.starts.last());
493추가: };
494추가: assert_eq!(destination, &scratch.0.join("sample"));
495추가: assert!(!destination.starts_with(&root));
496추가: }
497추가:
330498#[test]
331499fn explorer_double_click_does_not_open_executables() {
332500 let scratch = Folder::new();