team-ljyzipelo

공개

내구성 값으로 저장 미확인과 동기화 실패를 구분함

작성자
호시노 히나타
작성 시각
커밋
c33df7202a170e0ed46dd21525cac0af060a4e18
부모
3c558bd
이 시점의 파일 보기

변경된 파일 3개

+148-94
수정experiments/rust-ui-memory-app/src/archive_present.rs+27-3
@@ -9,6 +9,8 @@ pub const UNCERTAIN: &str = "저장이 끝났는지 확인하지 못했습니다
99pub const PARTIAL: &str = "일부 파일만 풀렸습니다. 풀린 파일은 풀 위치 폴더에 남아 있습니다.";
1010pub const LEFTOVERS: &str =
1111 "선택한 파일은 모두 저장했지만 임시 파일을 지우지 못했습니다. 풀 위치 폴더를 확인하세요.";
12추가: pub const SYNC_FAILED: &str =
13추가: "파일을 디스크에 완전히 저장하지 못했습니다. 풀 위치 폴더를 확인하세요.";
1214pub const SYNC_WARNING: &str = "파일을 디스크에 완전히 저장했는지 확인하지 못했습니다.";
1315pub const CLEANUP_WARNING: &str =
1416 "임시 파일을 지우지 못했습니다. 풀 위치 폴더에 남은 임시 파일이 있을 수 있습니다.";
@@ -147,12 +149,37 @@ pub fn target_directories(entries: &[Entry], selection: &Selection) -> BTreeSet<
147149 directories
148150}
149151
152추가: pub fn durability_warning(durability: Durability) -> Option<&'static str> {
153추가: match durability {
154추가: Durability::Failed => Some(SYNC_FAILED),
155추가: Durability::Unconfirmed => Some(SYNC_WARNING),
156추가: _ => None,
157추가: }
158추가: }
159추가:
150160pub fn warnings(
151161 terminal: Option<&Terminal>,
152162 confirmed: bool,
153163 targets: Option<&BTreeSet<String>>,
154164 directories: &BTreeSet<String>,
155165 outputs: &[(String, Disposition)],
166추가: ) -> Vec<&'static str> {
167추가: let mut result = publication_warnings(terminal, confirmed, targets, directories, outputs);
168추가: if let Some(warning) = terminal
169추가: .filter(|_| confirmed)
170추가: .and_then(|t| durability_warning(t.durability))
171추가: {
172추가: result.push(warning);
173추가: }
174추가: result
175추가: }
176추가:
177추가: pub fn publication_warnings(
178추가: terminal: Option<&Terminal>,
179추가: confirmed: bool,
180추가: targets: Option<&BTreeSet<String>>,
181추가: directories: &BTreeSet<String>,
182추가: outputs: &[(String, Disposition)],
156183) -> Vec<&'static str> {
157184 let Some(t) = terminal.filter(|_| confirmed) else {
158185 return vec![UNCERTAIN];
@@ -207,9 +234,6 @@ pub fn warnings(
207234 } else {
208235 result.push(UNCERTAIN);
209236 }
210삭제: if matches!(t.durability, Durability::Failed | Durability::Unconfirmed) {
211삭제: result.push(SYNC_WARNING);
212삭제: }
213237 if (retained || t.cleanup != Cleanup::Complete) && !all_saved_with_leftovers {
214238 result.push(CLEANUP_WARNING);
215239 }
수정experiments/rust-ui-memory-app/src/archive_screen.rs+16-8
@@ -853,7 +853,7 @@ impl ArchiveApp {
853853 let warnings = if listing {
854854 Vec::new()
855855 } else {
856삭제: present::warnings(
856추가: present::publication_warnings(
857857 t.as_ref(),
858858 self.model.confirmed,
859859 self.targets.as_ref(),
@@ -864,9 +864,14 @@ impl ArchiveApp {
864864 let success = self.model.confirmed
865865 && self.model.error.is_none()
866866 && t.as_ref().is_some_and(|t| t.outcome == Outcome::Completed)
867삭제: && warnings
868삭제: .iter()
869삭제: .all(|warning| *warning == present::SYNC_WARNING);
867추가: && warnings.is_empty();
868추가: let durability_warning = t
869추가: .as_ref()
870추가: .filter(|_| self.model.confirmed && !listing)
871추가: .and_then(|t| present::durability_warning(t.durability));
872추가: let durability_in_details = success
873추가: && t.as_ref()
874추가: .is_some_and(|t| t.durability == Durability::Unconfirmed);
870875 let cancelled =
871876 self.model.confirmed && t.as_ref().is_some_and(|t| t.outcome == Outcome::Cancelled);
872877 let title = if success {
@@ -933,11 +938,12 @@ impl ArchiveApp {
933938 }
934939 for warning in warnings
935940 .iter()
936삭제: .filter(|warning| !success || **warning != present::SYNC_WARNING)
941추가: .copied()
942추가: .chain(durability_warning.filter(|_| !durability_in_details))
937943 {
938944 ui.horizontal_wrapped(|ui| {
939945 theme::icon(ui, Icon::Warning, 20.0);
940삭제: ui.colored_label(theme::WARNING, *warning);
946추가: ui.colored_label(theme::WARNING, warning);
941947 });
942948 }
943949 if !success
@@ -952,8 +958,10 @@ impl ArchiveApp {
952958 }
953959 if self.details {
954960 theme::panel(theme::STRIPE).show(ui, |ui| {
955삭제: if success && warnings.contains(&present::SYNC_WARNING) {
956삭제: ui.label(present::SYNC_WARNING);
961추가: if durability_in_details {
962추가: if let Some(warning) = durability_warning {
963추가: ui.label(warning);
964추가: }
957965 }
958966 if let Some(t) = &t {
959967 for line in terminal_lines(t) {
수정tests/rust-app-ui/presentation.rs+105-83
@@ -1063,7 +1063,7 @@ mod widgets {
10631063 }
10641064
10651065 #[test]
1066삭제: fn completed_results_keep_folder_action_and_show_durability_only_in_details() {
1066추가: fn completed_results_keep_folder_action_and_distinguish_durability() {
10671067 for creating in [false, true] {
10681068 for durability in [
10691069 Durability::Synced,
@@ -1127,20 +1127,25 @@ mod widgets {
11271127 "{durability:?}: {shown:?}"
11281128 );
11291129 assert!(shown.iter().any(|(text, _)| text == "폴더 열기"));
1130삭제: assert!(
1131삭제: !shown
1132삭제: .iter()
1133삭제: .any(|(text, _)| text == "다시 시도" || text == SYNC_WARNING)
1130추가: assert!(!shown.iter().any(|(text, _)| text == "다시 시도"));
1131추가: assert!(!shown.iter().any(|(text, _)| text == SYNC_WARNING));
1132추가: assert_eq!(
1133추가: shown.iter().any(|(text, _)| text == "파일을 디스크에 완전히 저장하지 못했습니다. 풀 위치 폴더를 확인하세요."),
1134추가: durability == Durability::Failed
11341135 );
11351136 policy_click(&ctx, &mut app, "자세히 보기");
11361137 let details = policy_render(&ctx, &mut app, vec![]);
11371138 assert_eq!(
11381139 details.iter().any(|(text, _)| text == SYNC_WARNING),
1139삭제: durability != Durability::Synced
1140추가: durability == Durability::Unconfirmed
11401141 );
11411142 policy_click(&ctx, &mut app, "자세히 닫기");
11421143 let closed = policy_render(&ctx, &mut app, vec![]);
11431144 assert!(!closed.iter().any(|(text, _)| text == SYNC_WARNING));
1145추가: assert_eq!(
1146추가: closed.iter().any(|(text, _)| text == "파일을 디스크에 완전히 저장하지 못했습니다. 풀 위치 폴더를 확인하세요."),
1147추가: durability == Durability::Failed
1148추가: );
11441149 assert!(closed.iter().any(|(text, _)| text == "폴더 열기"));
11451150 }
11461151 }
@@ -1153,86 +1158,103 @@ mod widgets {
11531158 (Outcome::Failed, Publication::None, 0, 1),
11541159 (Outcome::Failed, Publication::Partial, 1, 2),
11551160 ] {
1156삭제: let scratch = Folder::new();
1157삭제: let factory = FakeFactory::default();
1158삭제: let mut app = loaded(&scratch, &factory);
1159삭제: app.model.entries = (0..expected_files)
1160삭제: .map(|id| Entry {
1161삭제: id,
1162삭제: name: format!("{id}.txt"),
1163삭제: kind: Kind::File,
1164삭제: bytes: Some(1),
1165삭제: packed: None,
1166삭제: encrypted: false,
1167삭제: })
1168삭제: .collect();
1169삭제: factory.state.borrow_mut().manual = true;
1170삭제: assert!(app.begin_extract());
1171삭제: {
1172삭제: let mut worker = factory.state.borrow_mut();
1173삭제: worker.frame(Event::Accepted { encryption: false });
1174삭제: if saved > 0 {
1175삭제: worker.frame(Event::Output {
1176삭제: entry_id: Some(0),
1177삭제: relative_name: "0.txt".into(),
1178삭제: disposition: Disposition::Created,
1179삭제: });
1180삭제: }
1181삭제: worker.finish(outcome, publication);
1182삭제: for event in &mut worker.queue {
1183삭제: if let HostEvent::Frame {
1184삭제: event: Event::Terminal(terminal),
1185삭제: ..
1186삭제: } = event
1187삭제: {
1188삭제: terminal.created_count = saved;
1189삭제: terminal.durability = Durability::Unconfirmed;
1190삭제: terminal.error = (outcome == Outcome::Failed).then_some(ErrorCode::Io);
1161추가: for durability in [
1162추가: Durability::Synced,
1163추가: Durability::Unconfirmed,
1164추가: Durability::Failed,
1165추가: ] {
1166추가: let scratch = Folder::new();
1167추가: let factory = FakeFactory::default();
1168추가: let mut app = loaded(&scratch, &factory);
1169추가: app.model.entries = (0..expected_files)
1170추가: .map(|id| Entry {
1171추가: id,
1172추가: name: format!("{id}.txt"),
1173추가: kind: Kind::File,
1174추가: bytes: Some(1),
1175추가: packed: None,
1176추가: encrypted: false,
1177추가: })
1178추가: .collect();
1179추가: factory.state.borrow_mut().manual = true;
1180추가: assert!(app.begin_extract());
1181추가: {
1182추가: let mut worker = factory.state.borrow_mut();
1183추가: worker.frame(Event::Accepted { encryption: false });
1184추가: if saved > 0 {
1185추가: worker.frame(Event::Output {
1186추가: entry_id: Some(0),
1187추가: relative_name: "0.txt".into(),
1188추가: disposition: Disposition::Created,
1189추가: });
1190추가: }
1191추가: worker.finish(outcome, publication);
1192추가: for event in &mut worker.queue {
1193추가: if let HostEvent::Frame {
1194추가: event: Event::Terminal(terminal),
1195추가: ..
1196추가: } = event
1197추가: {
1198추가: terminal.created_count = saved;
1199추가: terminal.durability = durability;
1200추가: terminal.error = (outcome == Outcome::Failed).then_some(ErrorCode::Io);
1201추가: }
11911202 }
11921203 }
1204추가: let ctx = egui::Context::default();
1205추가: for _ in 0..30 {
1206추가: policy_render(&ctx, &mut app, vec![]);
1207추가: }
1208추가: let completed = outcome == Outcome::Completed;
1209추가: let shown = policy_render(&ctx, &mut app, vec![]);
1210추가: let warning = match durability {
1211추가: Durability::Unconfirmed => Some(SYNC_WARNING),
1212추가: Durability::Failed => Some(
1213추가: "파일을 디스크에 완전히 저장하지 못했습니다. 풀 위치 폴더를 확인하세요.",
1214추가: ),
1215추가: _ => None,
1216추가: };
1217추가: let visible =
1218추가: warning.is_some() && !(completed && durability == Durability::Unconfirmed);
1219추가: assert_eq!(
1220추가: shown.iter().any(|(text, _)| Some(text.as_str()) == warning),
1221추가: visible,
1222추가: "{outcome:?}/{publication:?}: {shown:?}"
1223추가: );
1224추가: assert_eq!(shown.iter().any(|(text, _)| text == "폴더 열기"), completed);
1225추가: assert_eq!(
1226추가: shown.iter().any(|(text, _)| text == "압축을 풀었습니다"),
1227추가: completed
1228추가: );
1229추가: assert_eq!(
1230추가: shown
1231추가: .iter()
1232추가: .any(|(text, _)| text == "압축을 풀지 못했습니다"),
1233추가: !completed
1234추가: );
1235추가: assert_eq!(
1236추가: shown.iter().any(|(text, _)| text == PARTIAL),
1237추가: publication == Publication::Partial
1238추가: );
1239추가: policy_click(&ctx, &mut app, "자세히 보기");
1240추가: let details = policy_render(&ctx, &mut app, vec![]);
1241추가: assert_eq!(
1242추가: details
1243추가: .iter()
1244추가: .filter(|(text, _)| Some(text.as_str()) == warning)
1245추가: .count(),
1246추가: usize::from(warning.is_some()),
1247추가: "{outcome:?}/{publication:?}: {details:?}"
1248추가: );
1249추가: policy_click(&ctx, &mut app, "자세히 닫기");
1250추가: let closed = policy_render(&ctx, &mut app, vec![]);
1251추가: assert_eq!(
1252추가: closed
1253추가: .iter()
1254추가: .any(|(text, _)| Some(text.as_str()) == warning),
1255추가: visible
1256추가: );
11931257 }
1194삭제: let ctx = egui::Context::default();
1195삭제: for _ in 0..30 {
1196삭제: policy_render(&ctx, &mut app, vec![]);
1197삭제: }
1198삭제: let completed = outcome == Outcome::Completed;
1199삭제: let shown = policy_render(&ctx, &mut app, vec![]);
1200삭제: assert_eq!(
1201삭제: shown.iter().any(|(text, _)| text == SYNC_WARNING),
1202삭제: !completed,
1203삭제: "{outcome:?}/{publication:?}: {shown:?}"
1204삭제: );
1205삭제: assert_eq!(shown.iter().any(|(text, _)| text == "폴더 열기"), completed);
1206삭제: assert_eq!(
1207삭제: shown.iter().any(|(text, _)| text == "압축을 풀었습니다"),
1208삭제: completed
1209삭제: );
1210삭제: assert_eq!(
1211삭제: shown
1212삭제: .iter()
1213삭제: .any(|(text, _)| text == "압축을 풀지 못했습니다"),
1214삭제: !completed
1215삭제: );
1216삭제: assert_eq!(
1217삭제: shown.iter().any(|(text, _)| text == PARTIAL),
1218삭제: publication == Publication::Partial
1219삭제: );
1220삭제: policy_click(&ctx, &mut app, "자세히 보기");
1221삭제: let details = policy_render(&ctx, &mut app, vec![]);
1222삭제: assert_eq!(
1223삭제: details
1224삭제: .iter()
1225삭제: .filter(|(text, _)| text == SYNC_WARNING)
1226삭제: .count(),
1227삭제: 1,
1228삭제: "{outcome:?}/{publication:?}: {details:?}"
1229삭제: );
1230삭제: policy_click(&ctx, &mut app, "자세히 닫기");
1231삭제: let closed = policy_render(&ctx, &mut app, vec![]);
1232삭제: assert_eq!(
1233삭제: closed.iter().any(|(text, _)| text == SYNC_WARNING),
1234삭제: !completed
1235삭제: );
12361258 }
12371259 }
12381260