Merge pull request #62 from Team-LJY/features/rust-app-ui
가짜 작업자로 Rust 압축 앱 화면 흐름 구현
- 작성자
- LeeJunyoung
- 작성 시각
- 커밋
f2d2b566b14ac4fd09e9c3f93873a00af26ea334
변경된 파일 11개
+2,361-1| @@ -15,6 +15,7 @@ doctest = false | ||
| 15 | 15 | [features] |
| 16 | 16 | default = [] |
| 17 | 17 | ui = ["dep:eframe"] |
| 18 | 추가: ui-fixture = ["ui"] | |
| 18 | 19 | |
| 19 | 20 | [dependencies] |
| 20 | 21 | core_memory = { package = "zipelo-app-core-memory", path = "../rust-app-core-memory" } |
| @@ -22,9 +23,13 @@ eframe = { version = "=0.37.0", optional = true, default-features = false, featu | ||
| 22 | 23 | |
| 23 | 24 | [[bin]] |
| 24 | 25 | name = "zipelo-ui-memory-app" |
| 25 | 삭제: path = "src/app.rs" | |
| 26 | 추가: path = "src/desktop.rs" | |
| 26 | 27 | required-features = ["ui"] |
| 27 | 28 | |
| 28 | 29 | [[test]] |
| 29 | 30 | name = "ui_memory" |
| 30 | 31 | path = "../../tests/rust-ui-memory-app/regressions.rs" |
| 32 | 추가: | |
| 33 | 추가: [[test]] | |
| 34 | 추가: name = "archive_ui" | |
| 35 | 추가: path = "../../tests/rust-app-ui/regressions.rs" |
| @@ -0,0 +1,383 @@ | ||
| 1 | 추가: use crate::archive_ui::*; | |
| 2 | 추가: use eframe::egui; | |
| 3 | 추가: use std::path::PathBuf; | |
| 4 | 추가: | |
| 5 | 추가: pub struct ArchiveApp { | |
| 6 | 추가: pub model: Model, | |
| 7 | 추가: factory: Box<dyn Factory>, | |
| 8 | 추가: open_text: String, | |
| 9 | 추가: destination: String, | |
| 10 | 추가: gzip_name: String, | |
| 11 | 추가: sources: String, | |
| 12 | 추가: zip_output: String, | |
| 13 | 추가: password: String, | |
| 14 | 추가: create: bool, | |
| 15 | 추가: open: bool, | |
| 16 | 추가: selected_only: bool, | |
| 17 | 추가: method: Method, | |
| 18 | 추가: fixture: bool, | |
| 19 | 추가: } | |
| 20 | 추가: impl ArchiveApp { | |
| 21 | 추가: pub fn new(factory: Box<dyn Factory>, startup: Option<PathBuf>, fixture: bool) -> Self { | |
| 22 | 추가: let mut app = Self { | |
| 23 | 추가: model: Model::default(), | |
| 24 | 추가: factory, | |
| 25 | 추가: open_text: String::new(), | |
| 26 | 추가: destination: String::new(), | |
| 27 | 추가: gzip_name: String::new(), | |
| 28 | 추가: sources: String::new(), | |
| 29 | 추가: zip_output: String::new(), | |
| 30 | 추가: password: String::new(), | |
| 31 | 추가: create: false, | |
| 32 | 추가: open: false, | |
| 33 | 추가: selected_only: false, | |
| 34 | 추가: method: Method::Deflate, | |
| 35 | 추가: fixture, | |
| 36 | 추가: }; | |
| 37 | 추가: if let Some(path) = startup { | |
| 38 | 추가: app.open_path(path); | |
| 39 | 추가: } | |
| 40 | 추가: app | |
| 41 | 추가: } | |
| 42 | 추가: pub fn open_path(&mut self, archive: PathBuf) { | |
| 43 | 추가: self.password.clear(); | |
| 44 | 추가: self.model | |
| 45 | 추가: .begin(Start::List { archive }, self.factory.as_mut()); | |
| 46 | 추가: } | |
| 47 | 추가: fn on_drop(&mut self, paths: Vec<PathBuf>) { | |
| 48 | 추가: if self.model.busy() || paths.is_empty() { | |
| 49 | 추가: return; | |
| 50 | 추가: } | |
| 51 | 추가: if paths.len() == 1 && !self.create { | |
| 52 | 추가: self.open_path(paths[0].clone()); | |
| 53 | 추가: } else if paths.iter().all(|p| p.to_str().is_some()) { | |
| 54 | 추가: self.sources = paths | |
| 55 | 추가: .iter() | |
| 56 | 추가: .map(|p| p.to_str().unwrap()) | |
| 57 | 추가: .collect::<Vec<_>>() | |
| 58 | 추가: .join("\n"); | |
| 59 | 추가: self.create = true; | |
| 60 | 추가: } else { | |
| 61 | 추가: self.model.error = Some("ZIP 생성 경로는 현재 UTF-8 입력만 지원합니다".into()); | |
| 62 | 추가: } | |
| 63 | 추가: } | |
| 64 | 추가: } | |
| 65 | 추가: impl ArchiveApp { | |
| 66 | 추가: pub fn show(&mut self, root: &mut egui::Ui) { | |
| 67 | 추가: self.model.poll(); | |
| 68 | 추가: if self.model.challenge.is_none() { | |
| 69 | 추가: self.password.clear(); | |
| 70 | 추가: } | |
| 71 | 추가: let ctx = root.ctx().clone(); | |
| 72 | 추가: let dropped = ctx.input(|i| { | |
| 73 | 추가: i.raw | |
| 74 | 추가: .dropped_files | |
| 75 | 추가: .iter() | |
| 76 | 추가: .map(|f| f.path().to_path_buf()) | |
| 77 | 추가: .collect::<Vec<_>>() | |
| 78 | 추가: }); | |
| 79 | 추가: self.on_drop(dropped); | |
| 80 | 추가: if ctx.input(|i| i.viewport().close_requested()) { | |
| 81 | 추가: self.model.request_close(); | |
| 82 | 추가: if self.model.close != Close::Allowed { | |
| 83 | 추가: ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose); | |
| 84 | 추가: } | |
| 85 | 추가: } | |
| 86 | 추가: if self.model.close == Close::Allowed { | |
| 87 | 추가: ctx.send_viewport_cmd(egui::ViewportCommand::Close); | |
| 88 | 추가: } | |
| 89 | 추가: egui::Panel::top("archive-actions").show(root, |ui| { | |
| 90 | 추가: ui.horizontal_wrapped(|ui| { | |
| 91 | 추가: ui.heading("Zipelo"); | |
| 92 | 추가: ui.add_enabled_ui( | |
| 93 | 추가: !self.model.busy() && self.model.close == Close::Open, | |
| 94 | 추가: |ui| { | |
| 95 | 추가: if ui.button("파일 열기").clicked() { | |
| 96 | 추가: self.open = true; | |
| 97 | 추가: } | |
| 98 | 추가: if ui.button("ZIP 만들기").clicked() { | |
| 99 | 추가: self.create = true; | |
| 100 | 추가: } | |
| 101 | 추가: }, | |
| 102 | 추가: ); | |
| 103 | 추가: if ui | |
| 104 | 추가: .add_enabled(self.model.busy(), egui::Button::new("취소 요청")) | |
| 105 | 추가: .clicked() | |
| 106 | 추가: { | |
| 107 | 추가: self.password.clear(); | |
| 108 | 추가: self.model.cancel(); | |
| 109 | 추가: } | |
| 110 | 추가: }); | |
| 111 | 추가: if self.fixture { | |
| 112 | 추가: ui.colored_label( | |
| 113 | 추가: egui::Color32::from_rgb(143, 69, 0), | |
| 114 | 추가: "화면 시험 모드 / 파일을 읽거나 저장하지 않습니다", | |
| 115 | 추가: ); | |
| 116 | 추가: } | |
| 117 | 추가: }); | |
| 118 | 추가: egui::Panel::bottom("archive-status").show(root, |ui| { | |
| 119 | 추가: ui.label(self.model.status()); | |
| 120 | 추가: if let Some((stage, done, total, entries)) = | |
| 121 | 추가: self.model.progress.filter(|_| self.model.busy()) | |
| 122 | 추가: { | |
| 123 | 추가: ui.label(format!( | |
| 124 | 추가: "{} / {done}바이트 / {entries}개 처리", | |
| 125 | 추가: stage_label(stage) | |
| 126 | 추가: )); | |
| 127 | 추가: if let Some(total) = total.filter(|n| *n > 0) { | |
| 128 | 추가: ui.add( | |
| 129 | 추가: egui::ProgressBar::new((done as f64 / total as f64).clamp(0.0, 1.0) as f32) | |
| 130 | 추가: .show_percentage(), | |
| 131 | 추가: ); | |
| 132 | 추가: } else if self.model.busy() { | |
| 133 | 추가: ui.spinner(); | |
| 134 | 추가: } | |
| 135 | 추가: } | |
| 136 | 추가: if !self.model.busy() { | |
| 137 | 추가: if let Some(t) = &self.model.terminal { | |
| 138 | 추가: for line in terminal_lines(t) { | |
| 139 | 추가: ui.label(line); | |
| 140 | 추가: } | |
| 141 | 추가: } | |
| 142 | 추가: } | |
| 143 | 추가: }); | |
| 144 | 추가: egui::CentralPanel::default_margins().show(root, |ui| { | |
| 145 | 추가: if let Some(path) = &self.model.archive { | |
| 146 | 추가: ui.heading( | |
| 147 | 추가: path.file_name() | |
| 148 | 추가: .unwrap_or(path.as_os_str()) | |
| 149 | 추가: .to_string_lossy(), | |
| 150 | 추가: ); | |
| 151 | 추가: ui.label(path.display().to_string()); | |
| 152 | 추가: } else { | |
| 153 | 추가: ui.heading("압축파일을 여기로 끌어 놓으세요"); | |
| 154 | 추가: } | |
| 155 | 추가: if self.model.list_id.is_some() { | |
| 156 | 추가: ui.add_enabled_ui(self.model.can_extract(), |ui| { | |
| 157 | 추가: ui.horizontal_wrapped(|ui| { | |
| 158 | 추가: ui.label("출력 폴더"); | |
| 159 | 추가: ui.text_edit_singleline(&mut self.destination); | |
| 160 | 추가: }); | |
| 161 | 추가: if self | |
| 162 | 추가: .model | |
| 163 | 추가: .list_id | |
| 164 | 추가: .as_ref() | |
| 165 | 추가: .is_some_and(|id| id.format == Format::Gzip) | |
| 166 | 추가: { | |
| 167 | 추가: ui.horizontal(|ui| { | |
| 168 | 추가: ui.label("출력 파일명"); | |
| 169 | 추가: ui.text_edit_singleline(&mut self.gzip_name); | |
| 170 | 추가: }); | |
| 171 | 추가: } | |
| 172 | 추가: ui.horizontal_wrapped(|ui| { | |
| 173 | 추가: ui.checkbox(&mut self.selected_only, "선택한 항목만 풀기"); | |
| 174 | 추가: if ui.button("풀기").clicked() { | |
| 175 | 추가: self.model.extract( | |
| 176 | 추가: PathBuf::from(&self.destination), | |
| 177 | 추가: self.selected_only, | |
| 178 | 추가: self.model | |
| 179 | 추가: .list_id | |
| 180 | 추가: .as_ref() | |
| 181 | 추가: .filter(|id| id.format == Format::Gzip) | |
| 182 | 추가: .map(|_| self.gzip_name.clone()), | |
| 183 | 추가: self.factory.as_mut(), | |
| 184 | 추가: ); | |
| 185 | 추가: } | |
| 186 | 추가: }); | |
| 187 | 추가: }); | |
| 188 | 추가: } | |
| 189 | 추가: ui.separator(); | |
| 190 | 추가: egui::ScrollArea::both().show(ui, |ui| { | |
| 191 | 추가: egui::Grid::new("archive-list") | |
| 192 | 추가: .striped(true) | |
| 193 | 추가: .min_col_width(90.0) | |
| 194 | 추가: .show(ui, |ui| { | |
| 195 | 추가: ui.label("선택"); | |
| 196 | 추가: ui.label("이름"); | |
| 197 | 추가: ui.label("크기"); | |
| 198 | 추가: ui.label("형식"); | |
| 199 | 추가: ui.label("암호"); | |
| 200 | 추가: ui.end_row(); | |
| 201 | 추가: for entry in &self.model.entries { | |
| 202 | 추가: let mut selected = self.model.selected.contains(&entry.id); | |
| 203 | 추가: if ui | |
| 204 | 추가: .add_enabled( | |
| 205 | 추가: !self.model.busy() | |
| 206 | 추가: && matches!(entry.kind, Kind::File | Kind::Directory), | |
| 207 | 추가: egui::Checkbox::without_text(&mut selected), | |
| 208 | 추가: ) | |
| 209 | 추가: .on_hover_text(format!("{} 선택", entry.name)) | |
| 210 | 추가: .changed() | |
| 211 | 추가: { | |
| 212 | 추가: if selected { | |
| 213 | 추가: self.model.selected.insert(entry.id); | |
| 214 | 추가: } else { | |
| 215 | 추가: self.model.selected.remove(&entry.id); | |
| 216 | 추가: } | |
| 217 | 추가: } | |
| 218 | 추가: ui.label(&entry.name); | |
| 219 | 추가: ui.label( | |
| 220 | 추가: entry | |
| 221 | 추가: .bytes | |
| 222 | 추가: .map_or("알 수 없음".into(), |n| format!("{n} B")), | |
| 223 | 추가: ); | |
| 224 | 추가: ui.label(match entry.kind { | |
| 225 | 추가: Kind::File => "파일", | |
| 226 | 추가: Kind::Directory => "폴더", | |
| 227 | 추가: Kind::Link => "링크", | |
| 228 | 추가: Kind::Other => "기타", | |
| 229 | 추가: }); | |
| 230 | 추가: ui.label(if entry.encrypted { "있음" } else { "없음" }); | |
| 231 | 추가: ui.end_row(); | |
| 232 | 추가: } | |
| 233 | 추가: }); | |
| 234 | 추가: if self.model.entries.is_empty() && self.model.list_id.is_some() { | |
| 235 | 추가: ui.label("압축파일에 항목이 없습니다"); | |
| 236 | 추가: } | |
| 237 | 추가: for (name, state) in &self.model.outputs { | |
| 238 | 추가: ui.label(format!("{name}: {}", disposition_label(*state))); | |
| 239 | 추가: } | |
| 240 | 추가: }); | |
| 241 | 추가: }); | |
| 242 | 추가: if self.open { | |
| 243 | 추가: egui::Window::new("파일 열기") | |
| 244 | 추가: .collapsible(false) | |
| 245 | 추가: .show(&ctx, |ui| { | |
| 246 | 추가: ui.label("압축파일 절대 경로"); | |
| 247 | 추가: ui.text_edit_singleline(&mut self.open_text); | |
| 248 | 추가: if ui.button("열기").clicked() { | |
| 249 | 추가: self.open_path(self.open_text.clone().into()); | |
| 250 | 추가: self.open = false; | |
| 251 | 추가: } | |
| 252 | 추가: if ui.button("닫기").clicked() { | |
| 253 | 추가: self.open = false; | |
| 254 | 추가: } | |
| 255 | 추가: }); | |
| 256 | 추가: } | |
| 257 | 추가: if self.create { | |
| 258 | 추가: egui::Window::new("ZIP 만들기") | |
| 259 | 추가: .collapsible(false) | |
| 260 | 추가: .show(&ctx, |ui| { | |
| 261 | 추가: ui.add_enabled_ui(!self.model.busy(), |ui| { | |
| 262 | 추가: ui.label("원본 파일 절대 경로 / 한 줄에 하나"); | |
| 263 | 추가: ui.add(egui::TextEdit::multiline(&mut self.sources).desired_rows(4)); | |
| 264 | 추가: ui.label("저장할 ZIP 절대 경로"); | |
| 265 | 추가: ui.text_edit_singleline(&mut self.zip_output); | |
| 266 | 추가: ui.horizontal(|ui| { | |
| 267 | 추가: ui.selectable_value(&mut self.method, Method::Deflate, "압축"); | |
| 268 | 추가: ui.selectable_value(&mut self.method, Method::Store, "묶기"); | |
| 269 | 추가: }); | |
| 270 | 추가: ui.label("암호 ZIP 생성은 작업자 지원 후 활성화됩니다"); | |
| 271 | 추가: if ui.button("ZIP 만들기").clicked() { | |
| 272 | 추가: let sources = self | |
| 273 | 추가: .sources | |
| 274 | 추가: .lines() | |
| 275 | 추가: .map(|s| { | |
| 276 | 추가: let path = PathBuf::from(s); | |
| 277 | 추가: let name = path | |
| 278 | 추가: .file_name() | |
| 279 | 추가: .and_then(|n| n.to_str()) | |
| 280 | 추가: .unwrap_or("") | |
| 281 | 추가: .to_owned(); | |
| 282 | 추가: (path, name) | |
| 283 | 추가: }) | |
| 284 | 추가: .collect(); | |
| 285 | 추가: if self.model.begin( | |
| 286 | 추가: Start::CreateZip { | |
| 287 | 추가: sources, | |
| 288 | 추가: output_file: self.zip_output.clone().into(), | |
| 289 | 추가: method: self.method, | |
| 290 | 추가: aes256: false, | |
| 291 | 추가: }, | |
| 292 | 추가: self.factory.as_mut(), | |
| 293 | 추가: ) { | |
| 294 | 추가: self.create = false; | |
| 295 | 추가: } | |
| 296 | 추가: } | |
| 297 | 추가: }); | |
| 298 | 추가: if ui.button("닫기").clicked() { | |
| 299 | 추가: self.create = false; | |
| 300 | 추가: } | |
| 301 | 추가: }); | |
| 302 | 추가: } | |
| 303 | 추가: if let Some((_, attempt, encrypt)) = self.model.challenge { | |
| 304 | 추가: egui::Window::new(if encrypt { | |
| 305 | 추가: "ZIP 암호 설정" | |
| 306 | 추가: } else { | |
| 307 | 추가: "압축파일 암호" | |
| 308 | 추가: }) | |
| 309 | 추가: .collapsible(false) | |
| 310 | 추가: .show(&ctx, |ui| { | |
| 311 | 추가: ui.label(format!("암호 입력 요청 {attempt}")); | |
| 312 | 추가: let edit = ui.add( | |
| 313 | 추가: egui::TextEdit::singleline(&mut self.password) | |
| 314 | 추가: .password(true) | |
| 315 | 추가: .char_limit(1024), | |
| 316 | 추가: ); | |
| 317 | 추가: if ui.button("암호 전달").clicked() | |
| 318 | 추가: || (edit.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter))) | |
| 319 | 추가: { | |
| 320 | 추가: let text = std::mem::take(&mut self.password); | |
| 321 | 추가: self.model.password(text); | |
| 322 | 추가: } | |
| 323 | 추가: if ui.button("작업 취소").clicked() { | |
| 324 | 추가: self.password.clear(); | |
| 325 | 추가: self.model.cancel(); | |
| 326 | 추가: } | |
| 327 | 추가: }); | |
| 328 | 추가: } | |
| 329 | 추가: match self.model.close { | |
| 330 | 추가: Close::Confirm => { | |
| 331 | 추가: egui::Window::new("작업 중 닫기") | |
| 332 | 추가: .collapsible(false) | |
| 333 | 추가: .show(&ctx, |ui| { | |
| 334 | 추가: ui.label("취소를 요청하고 작업자 종료를 기다릴까요?"); | |
| 335 | 추가: if ui.button("계속 열기").clicked() { | |
| 336 | 추가: self.model.keep_open(); | |
| 337 | 추가: } | |
| 338 | 추가: if ui.button("취소 후 기다리기").clicked() { | |
| 339 | 추가: self.model.confirm_close(); | |
| 340 | 추가: } | |
| 341 | 추가: }); | |
| 342 | 추가: } | |
| 343 | 추가: Close::Waiting => { | |
| 344 | 추가: egui::Window::new("종료 확인 중") | |
| 345 | 추가: .collapsible(false) | |
| 346 | 추가: .show(&ctx, |ui| { | |
| 347 | 추가: ui.label("취소 결과와 프로세스 종료를 기다립니다"); | |
| 348 | 추가: if ui.button("닫기 철회").clicked() { | |
| 349 | 추가: self.model.keep_open(); | |
| 350 | 추가: } | |
| 351 | 추가: }); | |
| 352 | 추가: } | |
| 353 | 추가: Close::Review => { | |
| 354 | 추가: egui::Window::new("결과 확인 후 닫기") | |
| 355 | 추가: .collapsible(false) | |
| 356 | 추가: .show(&ctx, |ui| { | |
| 357 | 추가: ui.label(self.model.status()); | |
| 358 | 추가: if let Some(t) = &self.model.terminal { | |
| 359 | 추가: for line in terminal_lines(t) { | |
| 360 | 추가: ui.label(line); | |
| 361 | 추가: } | |
| 362 | 추가: } | |
| 363 | 추가: if ui.button("계속 열기").clicked() { | |
| 364 | 추가: self.model.keep_open(); | |
| 365 | 추가: } | |
| 366 | 추가: if ui.button("닫기").clicked() { | |
| 367 | 추가: self.model.acknowledge_close(); | |
| 368 | 추가: } | |
| 369 | 추가: }); | |
| 370 | 추가: } | |
| 371 | 추가: _ => {} | |
| 372 | 추가: } | |
| 373 | 추가: if self.model.busy() { | |
| 374 | 추가: ctx.request_repaint_after(std::time::Duration::from_millis(30)); | |
| 375 | 추가: } | |
| 376 | 추가: } | |
| 377 | 추가: } | |
| 378 | 추가: | |
| 379 | 추가: impl eframe::App for ArchiveApp { | |
| 380 | 추가: fn ui(&mut self, root: &mut egui::Ui, _: &mut eframe::Frame) { | |
| 381 | 추가: self.show(root); | |
| 382 | 추가: } | |
| 383 | 추가: } |
| @@ -0,0 +1,806 @@ | ||
| 1 | 추가: use std::{collections::BTreeSet, path::PathBuf}; | |
| 2 | 추가: | |
| 3 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 4 | 추가: pub enum Format { | |
| 5 | 추가: Zip, | |
| 6 | 추가: Tar, | |
| 7 | 추가: Gzip, | |
| 8 | 추가: TarGzip, | |
| 9 | 추가: } | |
| 10 | 추가: #[derive(Clone, Debug, Eq, PartialEq)] | |
| 11 | 추가: pub enum SourceObject { | |
| 12 | 추가: Unix { device: u64, inode: u64 }, | |
| 13 | 추가: Windows { volume: u64, file_id: [u8; 16] }, | |
| 14 | 추가: } | |
| 15 | 추가: #[derive(Clone, Debug, Eq, PartialEq)] | |
| 16 | 추가: pub struct ListId { | |
| 17 | 추가: pub catalog_version: u16, | |
| 18 | 추가: pub format: Format, | |
| 19 | 추가: pub source_object: SourceObject, | |
| 20 | 추가: pub archive_bytes: u64, | |
| 21 | 추가: pub archive_sha256: [u8; 32], | |
| 22 | 추가: } | |
| 23 | 추가: #[derive(Clone, Debug, Eq, PartialEq)] | |
| 24 | 추가: pub enum Selection { | |
| 25 | 추가: All, | |
| 26 | 추가: EntryIds(Vec<u32>), | |
| 27 | 추가: } | |
| 28 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 29 | 추가: pub enum Method { | |
| 30 | 추가: Store, | |
| 31 | 추가: Deflate, | |
| 32 | 추가: } | |
| 33 | 추가: #[derive(Clone, Debug, Eq, PartialEq)] | |
| 34 | 추가: pub enum Start { | |
| 35 | 추가: List { | |
| 36 | 추가: archive: PathBuf, | |
| 37 | 추가: }, | |
| 38 | 추가: Extract { | |
| 39 | 추가: archive: PathBuf, | |
| 40 | 추가: destination: PathBuf, | |
| 41 | 추가: selection: Selection, | |
| 42 | 추가: list_id: ListId, | |
| 43 | 추가: gzip_output_name: Option<String>, | |
| 44 | 추가: }, | |
| 45 | 추가: CreateZip { | |
| 46 | 추가: sources: Vec<(PathBuf, String)>, | |
| 47 | 추가: output_file: PathBuf, | |
| 48 | 추가: method: Method, | |
| 49 | 추가: aes256: bool, | |
| 50 | 추가: }, | |
| 51 | 추가: } | |
| 52 | 추가: // 암호를 Debug와 로그에서 제외하고 소유 버퍼를 해제 전에 지움. | |
| 53 | 추가: pub struct Secret(Vec<u8>); | |
| 54 | 추가: impl Secret { | |
| 55 | 추가: pub fn new(text: String) -> Result<Self, &'static str> { | |
| 56 | 추가: if text.is_empty() || text.len() > 1024 { | |
| 57 | 추가: return Err("암호는 UTF-8 1~1024바이트로 입력하세요"); | |
| 58 | 추가: } | |
| 59 | 추가: Ok(Self(text.into_bytes())) | |
| 60 | 추가: } | |
| 61 | 추가: pub fn as_bytes(&self) -> &[u8] { | |
| 62 | 추가: &self.0 | |
| 63 | 추가: } | |
| 64 | 추가: } | |
| 65 | 추가: impl Drop for Secret { | |
| 66 | 추가: fn drop(&mut self) { | |
| 67 | 추가: self.0.fill(0); | |
| 68 | 추가: } | |
| 69 | 추가: } | |
| 70 | 추가: pub enum Command { | |
| 71 | 추가: Start(Start), | |
| 72 | 추가: Password { challenge_id: u64, secret: Secret }, | |
| 73 | 추가: Cancel, | |
| 74 | 추가: } | |
| 75 | 추가: pub struct Request { | |
| 76 | 추가: pub job_id: u64, | |
| 77 | 추가: pub sequence: u64, | |
| 78 | 추가: pub command: Command, | |
| 79 | 추가: } | |
| 80 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 81 | 추가: pub enum Kind { | |
| 82 | 추가: File, | |
| 83 | 추가: Directory, | |
| 84 | 추가: Link, | |
| 85 | 추가: Other, | |
| 86 | 추가: } | |
| 87 | 추가: #[derive(Clone, Debug, Eq, PartialEq)] | |
| 88 | 추가: pub struct Entry { | |
| 89 | 추가: pub id: u32, | |
| 90 | 추가: pub name: String, | |
| 91 | 추가: pub kind: Kind, | |
| 92 | 추가: pub bytes: Option<u64>, | |
| 93 | 추가: pub packed: Option<u64>, | |
| 94 | 추가: pub encrypted: bool, | |
| 95 | 추가: } | |
| 96 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 97 | 추가: pub enum CancelStatus { | |
| 98 | 추가: Requested, | |
| 99 | 추가: AlreadyRequested, | |
| 100 | 추가: TooLate, | |
| 101 | 추가: Finished, | |
| 102 | 추가: } | |
| 103 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 104 | 추가: pub enum Stage { | |
| 105 | 추가: Scan, | |
| 106 | 추가: Read, | |
| 107 | 추가: Decode, | |
| 108 | 추가: Write, | |
| 109 | 추가: Verify, | |
| 110 | 추가: Commit, | |
| 111 | 추가: } | |
| 112 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 113 | 추가: pub enum Outcome { | |
| 114 | 추가: Completed, | |
| 115 | 추가: Failed, | |
| 116 | 추가: Cancelled, | |
| 117 | 추가: } | |
| 118 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 119 | 추가: pub enum ErrorCode { | |
| 120 | 추가: Integrity, | |
| 121 | 추가: UnsupportedFormat, | |
| 122 | 추가: UnsupportedFeature, | |
| 123 | 추가: WrongPassword, | |
| 124 | 추가: UnsafePath, | |
| 125 | 추가: Conflict, | |
| 126 | 추가: Limit, | |
| 127 | 추가: Io, | |
| 128 | 추가: Protocol, | |
| 129 | 추가: Internal, | |
| 130 | 추가: SourceChanged, | |
| 131 | 추가: InvalidRequest, | |
| 132 | 추가: } | |
| 133 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 134 | 추가: pub enum Publication { | |
| 135 | 추가: None, | |
| 136 | 추가: Partial, | |
| 137 | 추가: Complete, | |
| 138 | 추가: Uncertain, | |
| 139 | 추가: } | |
| 140 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 141 | 추가: pub enum Durability { | |
| 142 | 추가: NotApplicable, | |
| 143 | 추가: Synced, | |
| 144 | 추가: Unconfirmed, | |
| 145 | 추가: Failed, | |
| 146 | 추가: } | |
| 147 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 148 | 추가: pub enum Cleanup { | |
| 149 | 추가: Complete, | |
| 150 | 추가: Failed, | |
| 151 | 추가: Unconfirmed, | |
| 152 | 추가: } | |
| 153 | 추가: #[derive(Clone, Copy, Debug, Eq, PartialEq)] | |
| 154 | 추가: pub enum Disposition { | |
| 155 | 추가: Created, | |
| 156 | 추가: PartialRetained, | |
| 157 | 추가: Removed, | |
| 158 | 추가: CommitUncertain, | |
| 159 | 추가: } | |
| 160 | 추가: #[derive(Clone, Debug)] | |
| 161 | 추가: pub struct Terminal { | |
| 162 | 추가: pub outcome: Outcome, | |
| 163 | 추가: pub error: Option<ErrorCode>, | |
| 164 | 추가: pub publication: Publication, | |
| 165 | 추가: pub created_count: u64, | |
| 166 | 추가: pub retained_partial_count: u64, | |
| 167 | 추가: pub durability: Durability, | |
| 168 | 추가: pub cleanup: Cleanup, | |
| 169 | 추가: } | |
| 170 | 추가: #[derive(Clone, Debug)] | |
| 171 | 추가: pub enum Event { | |
| 172 | 추가: Accepted { | |
| 173 | 추가: encryption: bool, | |
| 174 | 추가: }, | |
| 175 | 추가: Entry(Entry), | |
| 176 | 추가: ListEnd { | |
| 177 | 추가: entry_count: u32, | |
| 178 | 추가: list_id: ListId, | |
| 179 | 추가: }, | |
| 180 | 추가: PasswordRequired { | |
| 181 | 추가: challenge_id: u64, | |
| 182 | 추가: attempt: u32, | |
| 183 | 추가: encrypt: bool, | |
| 184 | 추가: }, | |
| 185 | 추가: Progress { | |
| 186 | 추가: stage: Stage, | |
| 187 | 추가: processed: u64, | |
| 188 | 추가: total: Option<u64>, | |
| 189 | 추가: completed_entries: u64, | |
| 190 | 추가: }, | |
| 191 | 추가: Output { | |
| 192 | 추가: entry_id: Option<u32>, | |
| 193 | 추가: relative_name: String, | |
| 194 | 추가: disposition: Disposition, | |
| 195 | 추가: }, | |
| 196 | 추가: CancelAck { | |
| 197 | 추가: request_sequence: u64, | |
| 198 | 추가: status: CancelStatus, | |
| 199 | 추가: }, | |
| 200 | 추가: Terminal(Terminal), | |
| 201 | 추가: } | |
| 202 | 추가: pub enum HostEvent { | |
| 203 | 추가: Frame { | |
| 204 | 추가: job_id: u64, | |
| 205 | 추가: sequence: u64, | |
| 206 | 추가: event: Event, | |
| 207 | 추가: }, | |
| 208 | 추가: StdoutEof, | |
| 209 | 추가: StderrEof, | |
| 210 | 추가: Exited { | |
| 211 | 추가: success: bool, | |
| 212 | 추가: }, | |
| 213 | 추가: } | |
| 214 | 추가: // 바이트 codec과 프로세스 소유는 작업자 어댑터에서 담당함. | |
| 215 | 추가: // 전송 실패 후에도 poll로 양쪽 EOF와 자식 회수 결과를 전달함. | |
| 216 | 추가: pub trait Connection { | |
| 217 | 추가: fn send(&mut self, request: Request) -> Result<(), String>; | |
| 218 | 추가: fn poll(&mut self) -> Option<HostEvent>; | |
| 219 | 추가: } | |
| 220 | 추가: pub trait Factory { | |
| 221 | 추가: fn connect(&mut self, job_id: u64) -> Result<Box<dyn Connection>, String>; | |
| 222 | 추가: } | |
| 223 | 추가: pub struct Unavailable; | |
| 224 | 추가: impl Factory for Unavailable { | |
| 225 | 추가: fn connect(&mut self, _: u64) -> Result<Box<dyn Connection>, String> { | |
| 226 | 추가: Err("작업자 연결이 아직 준비되지 않았습니다".into()) | |
| 227 | 추가: } | |
| 228 | 추가: } | |
| 229 | 추가: struct Running { | |
| 230 | 추가: id: u64, | |
| 231 | 추가: outgoing: u64, | |
| 232 | 추가: incoming: u64, | |
| 233 | 추가: accepted: bool, | |
| 234 | 추가: start_failed: bool, | |
| 235 | 추가: start: Start, | |
| 236 | 추가: connection: Box<dyn Connection>, | |
| 237 | 추가: entries: Vec<Entry>, | |
| 238 | 추가: list_end: Option<(u32, ListId)>, | |
| 239 | 추가: stdout_eof: bool, | |
| 240 | 추가: stderr_eof: bool, | |
| 241 | 추가: exit: Option<bool>, | |
| 242 | 추가: cancel_sequence: Option<u64>, | |
| 243 | 추가: } | |
| 244 | 추가: #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] | |
| 245 | 추가: pub enum Close { | |
| 246 | 추가: #[default] | |
| 247 | 추가: Open, | |
| 248 | 추가: Confirm, | |
| 249 | 추가: Waiting, | |
| 250 | 추가: Review, | |
| 251 | 추가: Allowed, | |
| 252 | 추가: } | |
| 253 | 추가: #[derive(Default)] | |
| 254 | 추가: pub struct Model { | |
| 255 | 추가: running: Option<Running>, | |
| 256 | 추가: next_id: u64, | |
| 257 | 추가: pub archive: Option<PathBuf>, | |
| 258 | 추가: pub entries: Vec<Entry>, | |
| 259 | 추가: pub list_id: Option<ListId>, | |
| 260 | 추가: pub selected: BTreeSet<u32>, | |
| 261 | 추가: pub terminal: Option<Terminal>, | |
| 262 | 추가: pub challenge: Option<(u64, u32, bool)>, | |
| 263 | 추가: pub progress: Option<(Stage, u64, Option<u64>, u64)>, | |
| 264 | 추가: pub outputs: Vec<(String, Disposition)>, | |
| 265 | 추가: pub cancel: Option<CancelStatus>, | |
| 266 | 추가: pub error: Option<String>, | |
| 267 | 추가: pub encryption: bool, | |
| 268 | 추가: pub close: Close, | |
| 269 | 추가: pub confirmed: bool, | |
| 270 | 추가: } | |
| 271 | 추가: impl Model { | |
| 272 | 추가: pub fn busy(&self) -> bool { | |
| 273 | 추가: self.running.is_some() | |
| 274 | 추가: } | |
| 275 | 추가: pub fn job_id(&self) -> Option<u64> { | |
| 276 | 추가: self.running.as_ref().map(|r| r.id) | |
| 277 | 추가: } | |
| 278 | 추가: pub fn can_extract(&self) -> bool { | |
| 279 | 추가: !self.busy() | |
| 280 | 추가: && self.list_id.is_some() | |
| 281 | 추가: && self.archive.is_some() | |
| 282 | 추가: && self.close == Close::Open | |
| 283 | 추가: } | |
| 284 | 추가: pub fn begin(&mut self, start: Start, factory: &mut dyn Factory) -> bool { | |
| 285 | 추가: if self.busy() || self.close != Close::Open { | |
| 286 | 추가: return false; | |
| 287 | 추가: } | |
| 288 | 추가: let validation = match &start { | |
| 289 | 추가: Start::List { archive } => archive.is_absolute(), | |
| 290 | 추가: Start::Extract { | |
| 291 | 추가: archive, | |
| 292 | 추가: destination, | |
| 293 | 추가: selection, | |
| 294 | 추가: gzip_output_name, | |
| 295 | 추가: list_id, | |
| 296 | 추가: } => { | |
| 297 | 추가: archive.is_absolute() | |
| 298 | 추가: && destination.is_absolute() | |
| 299 | 추가: && self.archive.as_ref() == Some(archive) | |
| 300 | 추가: && self.list_id.as_ref() == Some(list_id) | |
| 301 | 추가: && match list_id.format { | |
| 302 | 추가: Format::Gzip => gzip_output_name.as_ref().is_some_and(|s| valid_leaf(s)), | |
| 303 | 추가: _ => gzip_output_name.is_none(), | |
| 304 | 추가: } | |
| 305 | 추가: && match selection { | |
| 306 | 추가: Selection::All => true, | |
| 307 | 추가: Selection::EntryIds(ids) => { | |
| 308 | 추가: !ids.is_empty() | |
| 309 | 추가: && ids.iter().collect::<BTreeSet<_>>().len() == ids.len() | |
| 310 | 추가: && ids.iter().all(|id| { | |
| 311 | 추가: self.entries.iter().any(|e| { | |
| 312 | 추가: e.id == *id | |
| 313 | 추가: && matches!(e.kind, Kind::File | Kind::Directory) | |
| 314 | 추가: }) | |
| 315 | 추가: }) | |
| 316 | 추가: } | |
| 317 | 추가: } | |
| 318 | 추가: } | |
| 319 | 추가: Start::CreateZip { | |
| 320 | 추가: sources, | |
| 321 | 추가: output_file, | |
| 322 | 추가: aes256, | |
| 323 | 추가: .. | |
| 324 | 추가: } => { | |
| 325 | 추가: !sources.is_empty() | |
| 326 | 추가: && output_file.is_absolute() | |
| 327 | 추가: && (!aes256 || self.encryption) | |
| 328 | 추가: && sources | |
| 329 | 추가: .iter() | |
| 330 | 추가: .all(|(p, n)| p.is_absolute() && valid_relative(n)) | |
| 331 | 추가: } | |
| 332 | 추가: }; | |
| 333 | 추가: if !validation { | |
| 334 | 추가: self.error = Some("입력 경로, 출력명과 선택한 목록을 확인하세요".into()); | |
| 335 | 추가: return false; | |
| 336 | 추가: } | |
| 337 | 추가: let Some(id) = self.next_id.checked_add(1) else { | |
| 338 | 추가: self.error = Some("작업 ID 한도에 도달했습니다".into()); | |
| 339 | 추가: return false; | |
| 340 | 추가: }; | |
| 341 | 추가: let mut connection = match factory.connect(id) { | |
| 342 | 추가: Ok(c) => c, | |
| 343 | 추가: Err(e) => { | |
| 344 | 추가: self.error = Some(e); | |
| 345 | 추가: return false; | |
| 346 | 추가: } | |
| 347 | 추가: }; | |
| 348 | 추가: let send_error = connection | |
| 349 | 추가: .send(Request { | |
| 350 | 추가: job_id: id, | |
| 351 | 추가: sequence: 0, | |
| 352 | 추가: command: Command::Start(start.clone()), | |
| 353 | 추가: }) | |
| 354 | 추가: .err(); | |
| 355 | 추가: let started = send_error.is_none(); | |
| 356 | 추가: if let Start::List { archive } = &start | |
| 357 | 추가: && started | |
| 358 | 추가: { | |
| 359 | 추가: self.archive = Some(archive.clone()); | |
| 360 | 추가: self.list_id = None; | |
| 361 | 추가: self.entries.clear(); | |
| 362 | 추가: self.selected.clear(); | |
| 363 | 추가: } | |
| 364 | 추가: self.next_id = id; | |
| 365 | 추가: self.terminal = None; | |
| 366 | 추가: self.challenge = None; | |
| 367 | 추가: self.progress = None; | |
| 368 | 추가: self.outputs.clear(); | |
| 369 | 추가: self.cancel = None; | |
| 370 | 추가: self.error = send_error; | |
| 371 | 추가: self.confirmed = false; | |
| 372 | 추가: self.running = Some(Running { | |
| 373 | 추가: id, | |
| 374 | 추가: outgoing: 1, | |
| 375 | 추가: incoming: 0, | |
| 376 | 추가: accepted: false, | |
| 377 | 추가: start_failed: !started, | |
| 378 | 추가: start, | |
| 379 | 추가: connection, | |
| 380 | 추가: entries: Vec::new(), | |
| 381 | 추가: list_end: None, | |
| 382 | 추가: stdout_eof: false, | |
| 383 | 추가: stderr_eof: false, | |
| 384 | 추가: exit: None, | |
| 385 | 추가: cancel_sequence: None, | |
| 386 | 추가: }); | |
| 387 | 추가: started | |
| 388 | 추가: } | |
| 389 | 추가: pub fn extract( | |
| 390 | 추가: &mut self, | |
| 391 | 추가: destination: PathBuf, | |
| 392 | 추가: selected_only: bool, | |
| 393 | 추가: gzip_output_name: Option<String>, | |
| 394 | 추가: factory: &mut dyn Factory, | |
| 395 | 추가: ) -> bool { | |
| 396 | 추가: if !self.can_extract() { | |
| 397 | 추가: return false; | |
| 398 | 추가: } | |
| 399 | 추가: self.begin( | |
| 400 | 추가: Start::Extract { | |
| 401 | 추가: archive: self.archive.clone().unwrap(), | |
| 402 | 추가: destination, | |
| 403 | 추가: selection: if selected_only { | |
| 404 | 추가: Selection::EntryIds(self.selected.iter().copied().collect()) | |
| 405 | 추가: } else { | |
| 406 | 추가: Selection::All | |
| 407 | 추가: }, | |
| 408 | 추가: list_id: self.list_id.clone().unwrap(), | |
| 409 | 추가: gzip_output_name, | |
| 410 | 추가: }, | |
| 411 | 추가: factory, | |
| 412 | 추가: ) | |
| 413 | 추가: } | |
| 414 | 추가: pub fn password(&mut self, text: String) -> bool { | |
| 415 | 추가: let Some((challenge_id, _, _)) = self.challenge else { | |
| 416 | 추가: return false; | |
| 417 | 추가: }; | |
| 418 | 추가: let secret = match Secret::new(text) { | |
| 419 | 추가: Ok(s) => s, | |
| 420 | 추가: Err(e) => { | |
| 421 | 추가: self.error = Some(e.into()); | |
| 422 | 추가: return false; | |
| 423 | 추가: } | |
| 424 | 추가: }; | |
| 425 | 추가: if self | |
| 426 | 추가: .send(Command::Password { | |
| 427 | 추가: challenge_id, | |
| 428 | 추가: secret, | |
| 429 | 추가: }) | |
| 430 | 추가: .is_some() | |
| 431 | 추가: { | |
| 432 | 추가: self.challenge = None; | |
| 433 | 추가: self.error = None; | |
| 434 | 추가: true | |
| 435 | 추가: } else { | |
| 436 | 추가: false | |
| 437 | 추가: } | |
| 438 | 추가: } | |
| 439 | 추가: fn send(&mut self, command: Command) -> Option<u64> { | |
| 440 | 추가: let run = self.running.as_mut()?; | |
| 441 | 추가: if run.start_failed || self.terminal.is_some() || run.exit.is_some() { | |
| 442 | 추가: return None; | |
| 443 | 추가: } | |
| 444 | 추가: let seq = run.outgoing; | |
| 445 | 추가: let Some(next) = seq.checked_add(1) else { | |
| 446 | 추가: self.error = Some("요청 순서 한도 초과".into()); | |
| 447 | 추가: return None; | |
| 448 | 추가: }; | |
| 449 | 추가: match run.connection.send(Request { | |
| 450 | 추가: job_id: run.id, | |
| 451 | 추가: sequence: seq, | |
| 452 | 추가: command, | |
| 453 | 추가: }) { | |
| 454 | 추가: Ok(()) => { | |
| 455 | 추가: run.outgoing = next; | |
| 456 | 추가: Some(seq) | |
| 457 | 추가: } | |
| 458 | 추가: Err(e) => { | |
| 459 | 추가: self.error = Some(e); | |
| 460 | 추가: None | |
| 461 | 추가: } | |
| 462 | 추가: } | |
| 463 | 추가: } | |
| 464 | 추가: pub fn cancel(&mut self) { | |
| 465 | 추가: if self | |
| 466 | 추가: .running | |
| 467 | 추가: .as_ref() | |
| 468 | 추가: .is_some_and(|r| r.cancel_sequence.is_none()) | |
| 469 | 추가: { | |
| 470 | 추가: if let Some(seq) = self.send(Command::Cancel) { | |
| 471 | 추가: self.running.as_mut().unwrap().cancel_sequence = Some(seq); | |
| 472 | 추가: self.challenge = None; | |
| 473 | 추가: } | |
| 474 | 추가: } | |
| 475 | 추가: } | |
| 476 | 추가: pub fn request_close(&mut self) { | |
| 477 | 추가: if self.close == Close::Open { | |
| 478 | 추가: self.close = if self.busy() { | |
| 479 | 추가: Close::Confirm | |
| 480 | 추가: } else { | |
| 481 | 추가: Close::Review | |
| 482 | 추가: }; | |
| 483 | 추가: } | |
| 484 | 추가: } | |
| 485 | 추가: pub fn confirm_close(&mut self) { | |
| 486 | 추가: if self.close == Close::Confirm { | |
| 487 | 추가: self.cancel(); | |
| 488 | 추가: self.close = if self.busy() { | |
| 489 | 추가: Close::Waiting | |
| 490 | 추가: } else { | |
| 491 | 추가: Close::Review | |
| 492 | 추가: }; | |
| 493 | 추가: } | |
| 494 | 추가: } | |
| 495 | 추가: pub fn keep_open(&mut self) { | |
| 496 | 추가: if self.close != Close::Allowed { | |
| 497 | 추가: self.close = Close::Open; | |
| 498 | 추가: } | |
| 499 | 추가: } | |
| 500 | 추가: pub fn acknowledge_close(&mut self) { | |
| 501 | 추가: if !self.busy() && self.close == Close::Review { | |
| 502 | 추가: self.close = Close::Allowed; | |
| 503 | 추가: } | |
| 504 | 추가: } | |
| 505 | 추가: pub fn poll(&mut self) { | |
| 506 | 추가: for _ in 0..128 { | |
| 507 | 추가: let Some(event) = self.running.as_mut().and_then(|r| r.connection.poll()) else { | |
| 508 | 추가: break; | |
| 509 | 추가: }; | |
| 510 | 추가: self.receive(event); | |
| 511 | 추가: } | |
| 512 | 추가: let complete = self | |
| 513 | 추가: .running | |
| 514 | 추가: .as_ref() | |
| 515 | 추가: .is_some_and(|r| r.stdout_eof && r.stderr_eof && r.exit.is_some()); | |
| 516 | 추가: if complete { | |
| 517 | 추가: let run = self.running.take().unwrap(); | |
| 518 | 추가: self.confirmed = | |
| 519 | 추가: self.terminal.is_some() && run.exit == Some(true) && self.error.is_none(); | |
| 520 | 추가: if !self.confirmed { | |
| 521 | 추가: self.error.get_or_insert( | |
| 522 | 추가: "작업자 종료 결과를 확인할 수 없습니다. 출력 상태를 확인하세요".into(), | |
| 523 | 추가: ); | |
| 524 | 추가: } | |
| 525 | 추가: if self.confirmed | |
| 526 | 추가: && self | |
| 527 | 추가: .terminal | |
| 528 | 추가: .as_ref() | |
| 529 | 추가: .is_some_and(|t| t.outcome == Outcome::Completed) | |
| 530 | 추가: { | |
| 531 | 추가: if matches!(run.start, Start::List { .. }) { | |
| 532 | 추가: if let Some((count, id)) = run | |
| 533 | 추가: .list_end | |
| 534 | 추가: .filter(|(n, _)| *n as usize == run.entries.len()) | |
| 535 | 추가: { | |
| 536 | 추가: let _ = count; | |
| 537 | 추가: self.entries = run.entries; | |
| 538 | 추가: self.list_id = Some(id); | |
| 539 | 추가: } else { | |
| 540 | 추가: self.error = Some("목록 완료 정보가 일치하지 않습니다. 다시 여세요".into()); | |
| 541 | 추가: self.confirmed = false; | |
| 542 | 추가: } | |
| 543 | 추가: } | |
| 544 | 추가: } | |
| 545 | 추가: if self | |
| 546 | 추가: .terminal | |
| 547 | 추가: .as_ref() | |
| 548 | 추가: .is_some_and(|t| t.error == Some(ErrorCode::SourceChanged)) | |
| 549 | 추가: { | |
| 550 | 추가: self.list_id = None; | |
| 551 | 추가: self.selected.clear(); | |
| 552 | 추가: } | |
| 553 | 추가: self.challenge = None; | |
| 554 | 추가: if matches!(self.close, Close::Waiting | Close::Confirm) { | |
| 555 | 추가: self.close = Close::Review; | |
| 556 | 추가: } | |
| 557 | 추가: } | |
| 558 | 추가: } | |
| 559 | 추가: fn receive(&mut self, host: HostEvent) { | |
| 560 | 추가: let run = self.running.as_mut().unwrap(); | |
| 561 | 추가: match host { | |
| 562 | 추가: HostEvent::StdoutEof => run.stdout_eof = true, | |
| 563 | 추가: HostEvent::StderrEof => run.stderr_eof = true, | |
| 564 | 추가: HostEvent::Exited { success } => run.exit = Some(success), | |
| 565 | 추가: HostEvent::Frame { | |
| 566 | 추가: job_id, | |
| 567 | 추가: sequence, | |
| 568 | 추가: event, | |
| 569 | 추가: } => { | |
| 570 | 추가: if job_id != run.id | |
| 571 | 추가: || sequence != run.incoming | |
| 572 | 추가: || self.terminal.is_some() | |
| 573 | 추가: || run.stdout_eof | |
| 574 | 추가: || sequence >= 1_000_000 | |
| 575 | 추가: { | |
| 576 | 추가: self.error = Some("작업자 응답 순서나 작업 ID가 일치하지 않습니다".into()); | |
| 577 | 추가: return; | |
| 578 | 추가: } | |
| 579 | 추가: run.incoming += 1; | |
| 580 | 추가: if !run.accepted && !matches!(event, Event::Accepted { .. }) { | |
| 581 | 추가: self.error = Some("작업 승인 응답이 없습니다".into()); | |
| 582 | 추가: return; | |
| 583 | 추가: } | |
| 584 | 추가: match event { | |
| 585 | 추가: Event::Accepted { encryption } => { | |
| 586 | 추가: if run.accepted { | |
| 587 | 추가: self.error = Some("작업 승인 중복".into()); | |
| 588 | 추가: } | |
| 589 | 추가: run.accepted = true; | |
| 590 | 추가: self.encryption = encryption; | |
| 591 | 추가: } | |
| 592 | 추가: Event::Entry(entry) => { | |
| 593 | 추가: if !matches!(run.start, Start::List { .. }) | |
| 594 | 추가: || run.list_end.is_some() | |
| 595 | 추가: || entry.id as usize != run.entries.len() | |
| 596 | 추가: || entry.name.len() > 4096 | |
| 597 | 추가: || run.entries.len() >= 100_000 | |
| 598 | 추가: { | |
| 599 | 추가: self.error = Some("목록 응답이 유효하지 않습니다".into()); | |
| 600 | 추가: } else { | |
| 601 | 추가: run.entries.push(entry); | |
| 602 | 추가: } | |
| 603 | 추가: } | |
| 604 | 추가: Event::ListEnd { | |
| 605 | 추가: entry_count, | |
| 606 | 추가: list_id, | |
| 607 | 추가: } => { | |
| 608 | 추가: if !matches!(run.start, Start::List { .. }) | |
| 609 | 추가: || run.list_end.is_some() | |
| 610 | 추가: || list_id.catalog_version != 1 | |
| 611 | 추가: { | |
| 612 | 추가: self.error = Some("목록 완료 응답이 유효하지 않습니다".into()); | |
| 613 | 추가: } else { | |
| 614 | 추가: run.list_end = Some((entry_count, list_id)); | |
| 615 | 추가: } | |
| 616 | 추가: } | |
| 617 | 추가: Event::PasswordRequired { | |
| 618 | 추가: challenge_id, | |
| 619 | 추가: attempt, | |
| 620 | 추가: encrypt, | |
| 621 | 추가: } => { | |
| 622 | 추가: if self.challenge.is_some() || challenge_id == 0 { | |
| 623 | 추가: self.error = Some("암호 요청이 유효하지 않습니다".into()); | |
| 624 | 추가: } else { | |
| 625 | 추가: self.challenge = Some((challenge_id, attempt, encrypt)); | |
| 626 | 추가: } | |
| 627 | 추가: } | |
| 628 | 추가: Event::Progress { | |
| 629 | 추가: stage, | |
| 630 | 추가: processed, | |
| 631 | 추가: total, | |
| 632 | 추가: completed_entries, | |
| 633 | 추가: } => self.progress = Some((stage, processed, total, completed_entries)), | |
| 634 | 추가: Event::Output { | |
| 635 | 추가: relative_name, | |
| 636 | 추가: disposition, | |
| 637 | 추가: .. | |
| 638 | 추가: } => { | |
| 639 | 추가: if self.outputs.len() < 100_000 && relative_name.len() <= 4096 { | |
| 640 | 추가: self.outputs.push((relative_name, disposition)); | |
| 641 | 추가: } else { | |
| 642 | 추가: self.error = Some("출력 보고 한도 초과".into()); | |
| 643 | 추가: } | |
| 644 | 추가: } | |
| 645 | 추가: Event::CancelAck { | |
| 646 | 추가: request_sequence, | |
| 647 | 추가: status, | |
| 648 | 추가: } => { | |
| 649 | 추가: if run.cancel_sequence == Some(request_sequence) && self.cancel.is_none() { | |
| 650 | 추가: self.cancel = Some(status); | |
| 651 | 추가: } else { | |
| 652 | 추가: self.error = Some("취소 응답이 요청과 일치하지 않습니다".into()); | |
| 653 | 추가: } | |
| 654 | 추가: } | |
| 655 | 추가: Event::Terminal(t) => { | |
| 656 | 추가: self.challenge = None; | |
| 657 | 추가: self.terminal = Some(t); | |
| 658 | 추가: } | |
| 659 | 추가: } | |
| 660 | 추가: } | |
| 661 | 추가: } | |
| 662 | 추가: } | |
| 663 | 추가: pub fn status(&self) -> String { | |
| 664 | 추가: if let Some(error) = &self.error { | |
| 665 | 추가: return error.clone(); | |
| 666 | 추가: } | |
| 667 | 추가: if self.busy() { | |
| 668 | 추가: if self.terminal.is_some() { | |
| 669 | 추가: return "작업 결과 수신 / 프로세스 종료 확인 중".into(); | |
| 670 | 추가: } | |
| 671 | 추가: if self.challenge.is_some() { | |
| 672 | 추가: return "암호를 입력하세요".into(); | |
| 673 | 추가: } | |
| 674 | 추가: if let Some(c) = self.cancel { | |
| 675 | 추가: return match c { | |
| 676 | 추가: CancelStatus::Requested | CancelStatus::AlreadyRequested => { | |
| 677 | 추가: "취소 요청 접수 / 최종 결과 대기" | |
| 678 | 추가: } | |
| 679 | 추가: CancelStatus::TooLate => "취소할 수 없는 단계 / 최종 결과 대기", | |
| 680 | 추가: CancelStatus::Finished => "처리 종료 응답 / 프로세스 종료 확인 중", | |
| 681 | 추가: } | |
| 682 | 추가: .into(); | |
| 683 | 추가: } | |
| 684 | 추가: if self | |
| 685 | 추가: .running | |
| 686 | 추가: .as_ref() | |
| 687 | 추가: .is_some_and(|r| r.cancel_sequence.is_some()) | |
| 688 | 추가: { | |
| 689 | 추가: return "취소 요청 전송 / 최종 결과 대기".into(); | |
| 690 | 추가: } | |
| 691 | 추가: return "작업 중".into(); | |
| 692 | 추가: } | |
| 693 | 추가: match self | |
| 694 | 추가: .terminal | |
| 695 | 추가: .as_ref() | |
| 696 | 추가: .filter(|_| self.confirmed) | |
| 697 | 추가: .map(|t| t.outcome) | |
| 698 | 추가: { | |
| 699 | 추가: Some(Outcome::Completed) => "작업 완료", | |
| 700 | 추가: Some(Outcome::Cancelled) => "작업 취소됨", | |
| 701 | 추가: Some(Outcome::Failed) => "작업 실패", | |
| 702 | 추가: None => "압축파일을 열거나 ZIP 파일을 만드세요", | |
| 703 | 추가: } | |
| 704 | 추가: .into() | |
| 705 | 추가: } | |
| 706 | 추가: } | |
| 707 | 추가: pub fn valid_leaf(name: &str) -> bool { | |
| 708 | 추가: valid_relative(name) && !name.contains('/') && !name.contains('\\') | |
| 709 | 추가: } | |
| 710 | 추가: pub fn valid_relative(name: &str) -> bool { | |
| 711 | 추가: !name.is_empty() | |
| 712 | 추가: && !name.contains('\0') | |
| 713 | 추가: && !name.contains(':') | |
| 714 | 추가: && !name.starts_with('/') | |
| 715 | 추가: && !name.starts_with('\\') | |
| 716 | 추가: && name | |
| 717 | 추가: .split(['/', '\\']) | |
| 718 | 추가: .all(|p| !p.is_empty() && p != "." && p != "..") | |
| 719 | 추가: } | |
| 720 | 추가: | |
| 721 | 추가: // 파일 연결로 전달된 원형 경로를 손실 변환 없이 보존함. | |
| 722 | 추가: pub fn launch_args( | |
| 723 | 추가: args: Vec<std::ffi::OsString>, | |
| 724 | 추가: cwd: PathBuf, | |
| 725 | 추가: ) -> Result<(bool, Option<PathBuf>), &'static str> { | |
| 726 | 추가: let fixture = args.iter().any(|arg| arg == "--ui-fixture"); | |
| 727 | 추가: let paths = args | |
| 728 | 추가: .into_iter() | |
| 729 | 추가: .filter(|arg| arg != "--ui-fixture") | |
| 730 | 추가: .collect::<Vec<_>>(); | |
| 731 | 추가: if paths.len() > 1 { | |
| 732 | 추가: return Err("압축파일 하나를 지정하세요"); | |
| 733 | 추가: } | |
| 734 | 추가: let path = paths | |
| 735 | 추가: .into_iter() | |
| 736 | 추가: .next() | |
| 737 | 추가: .map(PathBuf::from) | |
| 738 | 추가: .map(|p| if p.is_absolute() { p } else { cwd.join(p) }); | |
| 739 | 추가: Ok((fixture, path)) | |
| 740 | 추가: } | |
| 741 | 추가: | |
| 742 | 추가: pub fn stage_label(stage: Stage) -> &'static str { | |
| 743 | 추가: match stage { | |
| 744 | 추가: Stage::Scan => "목록 읽는 중", | |
| 745 | 추가: Stage::Read => "파일 읽는 중", | |
| 746 | 추가: Stage::Decode => "압축 푸는 중", | |
| 747 | 추가: Stage::Write => "파일 쓰는 중", | |
| 748 | 추가: Stage::Verify => "검증 중", | |
| 749 | 추가: Stage::Commit => "저장 마무리 중", | |
| 750 | 추가: } | |
| 751 | 추가: } | |
| 752 | 추가: pub fn disposition_label(disposition: Disposition) -> &'static str { | |
| 753 | 추가: match disposition { | |
| 754 | 추가: Disposition::Created => "생성됨", | |
| 755 | 추가: Disposition::PartialRetained => "일부 파일 남음", | |
| 756 | 추가: Disposition::Removed => "작업 임시 파일 정리됨", | |
| 757 | 추가: Disposition::CommitUncertain => "저장 여부 불확실", | |
| 758 | 추가: } | |
| 759 | 추가: } | |
| 760 | 추가: pub fn terminal_lines(t: &Terminal) -> Vec<String> { | |
| 761 | 추가: let publication = match t.publication { | |
| 762 | 추가: Publication::None => "게시된 파일 없음", | |
| 763 | 추가: Publication::Partial => "일부 파일 게시됨", | |
| 764 | 추가: Publication::Complete => "파일 게시 완료", | |
| 765 | 추가: Publication::Uncertain => "파일 게시 여부 불확실 / 출력 폴더를 확인하세요", | |
| 766 | 추가: }; | |
| 767 | 추가: let durability = match t.durability { | |
| 768 | 추가: Durability::NotApplicable => "동기화 해당 없음", | |
| 769 | 추가: Durability::Synced => "디스크 동기화 완료", | |
| 770 | 추가: Durability::Unconfirmed => "디스크 동기화 미확인", | |
| 771 | 추가: Durability::Failed => "디스크 동기화 실패", | |
| 772 | 추가: }; | |
| 773 | 추가: let cleanup = match t.cleanup { | |
| 774 | 추가: Cleanup::Complete => "작업 임시 파일 정리 완료", | |
| 775 | 추가: Cleanup::Failed => "작업 임시 파일 정리 실패", | |
| 776 | 추가: Cleanup::Unconfirmed => "작업 임시 파일 정리 미확인", | |
| 777 | 추가: }; | |
| 778 | 추가: let mut lines = vec![ | |
| 779 | 추가: publication.into(), | |
| 780 | 추가: format!( | |
| 781 | 추가: "생성 {}개 / 남은 임시 파일 {}개", | |
| 782 | 추가: t.created_count, t.retained_partial_count | |
| 783 | 추가: ), | |
| 784 | 추가: format!("{durability} / {cleanup}"), | |
| 785 | 추가: ]; | |
| 786 | 추가: if let Some(error) = t.error { | |
| 787 | 추가: lines.push( | |
| 788 | 추가: match error { | |
| 789 | 추가: ErrorCode::Integrity => "압축파일이 손상됐습니다", | |
| 790 | 추가: ErrorCode::UnsupportedFormat => "지원하지 않는 압축 형식입니다", | |
| 791 | 추가: ErrorCode::UnsupportedFeature => "아직 지원하지 않는 기능입니다", | |
| 792 | 추가: ErrorCode::WrongPassword => "암호가 올바르지 않습니다", | |
| 793 | 추가: ErrorCode::UnsafePath => "안전하지 않은 경로가 있어 중단했습니다", | |
| 794 | 추가: ErrorCode::Conflict => "같은 이름의 파일이 있습니다. 다른 출력 폴더를 선택하세요", | |
| 795 | 추가: ErrorCode::Limit => "처리 한도를 초과했습니다", | |
| 796 | 추가: ErrorCode::Io => "파일을 읽거나 쓰지 못했습니다", | |
| 797 | 추가: ErrorCode::Protocol => "작업자 응답이 올바르지 않습니다", | |
| 798 | 추가: ErrorCode::Internal => "작업자 처리 오류입니다", | |
| 799 | 추가: ErrorCode::SourceChanged => "원본 파일이 바뀌었습니다. 압축파일을 다시 여세요", | |
| 800 | 추가: ErrorCode::InvalidRequest => "입력과 선택한 항목을 확인하세요", | |
| 801 | 추가: } | |
| 802 | 추가: .into(), | |
| 803 | 추가: ); | |
| 804 | 추가: } | |
| 805 | 추가: lines | |
| 806 | 추가: } |
| @@ -0,0 +1,68 @@ | ||
| 1 | 추가: #[cfg(feature = "ui-fixture")] | |
| 2 | 추가: #[path = "../../../tests/rust-app-ui/fake.rs"] | |
| 3 | 추가: mod fake; | |
| 4 | 추가: #[path = "system_font.rs"] | |
| 5 | 추가: mod system_font; | |
| 6 | 추가: use eframe::egui::{self, Color32, FontData, FontDefinitions, FontFamily, FontId, TextStyle}; | |
| 7 | 추가: fn main() -> eframe::Result { | |
| 8 | 추가: let font = system_font::load().map_err(|e| eframe::Error::AppCreation(Box::new(e)))?; | |
| 9 | 추가: eframe::run_native( | |
| 10 | 추가: "Zipelo", | |
| 11 | 추가: eframe::NativeOptions { | |
| 12 | 추가: renderer: eframe::Renderer::Glow, | |
| 13 | 추가: viewport: egui::ViewportBuilder::default() | |
| 14 | 추가: .with_inner_size([1060.0, 720.0]) | |
| 15 | 추가: .with_min_inner_size([760.0, 540.0]), | |
| 16 | 추가: ..Default::default() | |
| 17 | 추가: }, | |
| 18 | 추가: Box::new(move |cc| { | |
| 19 | 추가: let mut fonts = FontDefinitions::empty(); | |
| 20 | 추가: let mut data = FontData::from_owned(font.bytes); | |
| 21 | 추가: data.index = font.face_index; | |
| 22 | 추가: fonts.font_data.insert("noto-kr".into(), data.into()); | |
| 23 | 추가: fonts | |
| 24 | 추가: .families | |
| 25 | 추가: .insert(FontFamily::Proportional, vec!["noto-kr".into()]); | |
| 26 | 추가: cc.egui_ctx.set_fonts(fonts); | |
| 27 | 추가: cc.egui_ctx.set_visuals(egui::Visuals::light()); | |
| 28 | 추가: cc.egui_ctx.style_mut_of(egui::Theme::Light, |style| { | |
| 29 | 추가: style | |
| 30 | 추가: .text_styles | |
| 31 | 추가: .insert(TextStyle::Body, FontId::proportional(18.0)); | |
| 32 | 추가: style | |
| 33 | 추가: .text_styles | |
| 34 | 추가: .insert(TextStyle::Button, FontId::proportional(18.0)); | |
| 35 | 추가: style | |
| 36 | 추가: .text_styles | |
| 37 | 추가: .insert(TextStyle::Heading, FontId::proportional(26.0)); | |
| 38 | 추가: style.visuals.panel_fill = Color32::WHITE; | |
| 39 | 추가: style.visuals.override_text_color = Some(Color32::from_rgb(24, 39, 57)); | |
| 40 | 추가: style.visuals.selection.bg_fill = Color32::from_rgb(211, 230, 246); | |
| 41 | 추가: style.spacing.item_spacing = egui::vec2(12.0, 10.0); | |
| 42 | 추가: style.spacing.button_padding = egui::vec2(14.0, 10.0); | |
| 43 | 추가: }); | |
| 44 | 추가: let (fixture, startup) = zipelo_ui_memory_app::archive_ui::launch_args( | |
| 45 | 추가: std::env::args_os().skip(1).collect(), | |
| 46 | 추가: std::env::current_dir()?, | |
| 47 | 추가: ) | |
| 48 | 추가: .map_err(std::io::Error::other)?; | |
| 49 | 추가: let factory: Box<dyn zipelo_ui_memory_app::archive_ui::Factory> = if fixture { | |
| 50 | 추가: #[cfg(feature = "ui-fixture")] | |
| 51 | 추가: { | |
| 52 | 추가: Box::new(fake::FakeFactory::default()) | |
| 53 | 추가: } | |
| 54 | 추가: #[cfg(not(feature = "ui-fixture"))] | |
| 55 | 추가: { | |
| 56 | 추가: return Err(Box::new(std::io::Error::other( | |
| 57 | 추가: "ui-fixture feature가 필요합니다", | |
| 58 | 추가: ))); | |
| 59 | 추가: } | |
| 60 | 추가: } else { | |
| 61 | 추가: Box::new(zipelo_ui_memory_app::archive_ui::Unavailable) | |
| 62 | 추가: }; | |
| 63 | 추가: Ok(Box::new( | |
| 64 | 추가: zipelo_ui_memory_app::archive_screen::ArchiveApp::new(factory, startup, fixture), | |
| 65 | 추가: )) | |
| 66 | 추가: }), | |
| 67 | 추가: ) | |
| 68 | 추가: } |
| @@ -4,3 +4,8 @@ pub use core_memory as core; | ||
| 4 | 4 | pub mod controller; |
| 5 | 5 | pub mod runtime; |
| 6 | 6 | pub mod transport; |
| 7 | 추가: | |
| 8 | 추가: pub mod archive_ui; | |
| 9 | 추가: | |
| 10 | 추가: #[cfg(feature = "ui")] | |
| 11 | 추가: pub mod archive_screen; |
| @@ -0,0 +1,3 @@ | ||
| 1 | 추가: screens/ | |
| 2 | 추가: screens-*/ | |
| 3 | 추가: __pycache__/ |
| @@ -0,0 +1,19 @@ | ||
| 1 | 추가: # 앱 화면 흐름 시험 | |
| 2 | 추가: | |
| 3 | 추가: 가짜 작업자는 계약 revision 2의 의미를 따르는 프론트엔드 어댑터임. 바이너리 codec, 실제 프로세스 실행, 파일 읽기와 쓰기, 암호 해독은 수행하지 않음. 실제 codec은 backend 소유이며 이 PR에서 중복 구현하지 않음. | |
| 4 | 추가: | |
| 5 | 추가: `python3 tests/ci/run_rust.py local`은 기존 시험과 새 `archive_ui` 시험을 all-features로 실행함. Windows 결과는 교차 빌드이며 Windows 실제 실행은 별도 확인해야 함. | |
| 6 | 추가: | |
| 7 | 추가: 화면 직접 확인: | |
| 8 | 추가: | |
| 9 | 추가: ```sh | |
| 10 | 추가: cargo +1.99.1 run --locked --manifest-path experiments/rust-ui-memory-app/Cargo.toml --features ui-fixture -- --ui-fixture /absolute/example.zip | |
| 11 | 추가: ``` | |
| 12 | 추가: | |
| 13 | 추가: `locked.zip` 이름은 가짜 암호 요청을 만듦. 아무 비어 있지 않은 합성 암호를 받으며 암호를 기록하거나 저장하지 않음. 실제 암호나 사용자 자료를 입력할 필요가 없음. 시험 모드는 화면에 명시되고 실제 파일을 만들지 않음. `ui-fixture` 없이 실행하면 작업자 미연결 오류를 표시하며 가짜 성공으로 대체하지 않음. | |
| 14 | 추가: | |
| 15 | 추가: 범위는 목록 확인, 선택 해제, GZ 출력명, ZIP 생성, 암호 요청, 진행률, 취소와 닫기 철회, Terminal/EOF/child wait 분리, 오래된 ID/sequence 거부, SourceChanged 재열람, 부분 출력과 불확실 게시 보존임. 구성한 이벤트 시험은 실제 OS 종료나 파일 보안 검증의 증거가 아님. | |
| 16 | 추가: | |
| 17 | 추가: 디자인은 흰 바탕 #FFFFFF, 글자 #182739, 선택 #D3E6F6, 강조 #174C7C를 사용함. 기존 한글 시스템 폰트와 본문/버튼 18px, 제목 26px를 유지함. 상단 작업 버튼, 가운데 파일 목록, 하단 진행/결과의 왼쪽 정렬 구조이며 작은 부가 설명, 장식 카드와 새 아이콘을 추가하지 않음. | |
| 18 | 추가: | |
| 19 | 추가: 풀기 버튼은 raw GZ에만 출력명을 보내며 ZIP/TAR/TAR.GZ에는 None을 보냄. 모델과 가짜 작업자도 이 계약을 검증함. Start 전송 실패 시에는 연결을 보존하고 추가 요청을 막으며, 양쪽 EOF와 child wait가 모두 올 때까지 교체와 닫기를 허용하지 않음. 이때 Terminal이 없어도 종료 후 오류 확인 화면으로 이동하며 성공으로 표시하지 않음. |
| @@ -0,0 +1,213 @@ | ||
| 1 | 추가: use std::{cell::RefCell, collections::VecDeque, rc::Rc}; | |
| 2 | 추가: use zipelo_ui_memory_app::archive_ui::*; | |
| 3 | 추가: | |
| 4 | 추가: #[derive(Default)] | |
| 5 | 추가: pub struct State { | |
| 6 | 추가: pub requests: Vec<(u64, &'static str)>, | |
| 7 | 추가: pub starts: Vec<Start>, | |
| 8 | 추가: pub password_seen: bool, | |
| 9 | 추가: pub job: u64, | |
| 10 | 추가: sequence: u64, | |
| 11 | 추가: pub queue: VecDeque<HostEvent>, | |
| 12 | 추가: pub manual: bool, | |
| 13 | 추가: pub list_format: Option<Format>, | |
| 14 | 추가: pub fail_start: bool, | |
| 15 | 추가: pub dropped_connections: usize, | |
| 16 | 추가: pause: bool, | |
| 17 | 추가: } | |
| 18 | 추가: #[derive(Default, Clone)] | |
| 19 | 추가: pub struct FakeFactory { | |
| 20 | 추가: pub state: Rc<RefCell<State>>, | |
| 21 | 추가: } | |
| 22 | 추가: impl FakeFactory { | |
| 23 | 추가: pub fn manual() -> Self { | |
| 24 | 추가: let f = Self::default(); | |
| 25 | 추가: f.state.borrow_mut().manual = true; | |
| 26 | 추가: f | |
| 27 | 추가: } | |
| 28 | 추가: } | |
| 29 | 추가: impl State { | |
| 30 | 추가: pub fn frame(&mut self, event: Event) { | |
| 31 | 추가: let sequence = self.sequence; | |
| 32 | 추가: self.sequence += 1; | |
| 33 | 추가: self.queue.push_back(HostEvent::Frame { | |
| 34 | 추가: job_id: self.job, | |
| 35 | 추가: sequence, | |
| 36 | 추가: event, | |
| 37 | 추가: }); | |
| 38 | 추가: } | |
| 39 | 추가: pub fn finish(&mut self, outcome: Outcome, publication: Publication) { | |
| 40 | 추가: self.frame(Event::Terminal(Terminal { | |
| 41 | 추가: outcome, | |
| 42 | 추가: error: None, | |
| 43 | 추가: publication, | |
| 44 | 추가: created_count: if publication == Publication::Complete { | |
| 45 | 추가: 1 | |
| 46 | 추가: } else { | |
| 47 | 추가: 0 | |
| 48 | 추가: }, | |
| 49 | 추가: retained_partial_count: 0, | |
| 50 | 추가: durability: Durability::Synced, | |
| 51 | 추가: cleanup: Cleanup::Complete, | |
| 52 | 추가: })); | |
| 53 | 추가: self.queue.push_back(HostEvent::StdoutEof); | |
| 54 | 추가: self.queue.push_back(HostEvent::StderrEof); | |
| 55 | 추가: self.queue.push_back(HostEvent::Exited { success: true }); | |
| 56 | 추가: } | |
| 57 | 추가: fn complete_action(&mut self) { | |
| 58 | 추가: match self.starts.last().cloned().unwrap() { | |
| 59 | 추가: Start::List { archive } => { | |
| 60 | 추가: self.frame(Event::Entry(Entry { | |
| 61 | 추가: id: 0, | |
| 62 | 추가: name: "읽어주세요.txt".into(), | |
| 63 | 추가: kind: Kind::File, | |
| 64 | 추가: bytes: Some(31), | |
| 65 | 추가: packed: Some(54), | |
| 66 | 추가: encrypted: false, | |
| 67 | 추가: })); | |
| 68 | 추가: let format = self.list_format.unwrap_or_else(|| { | |
| 69 | 추가: if archive.extension().is_some_and(|x| x == "gz") { | |
| 70 | 추가: Format::Gzip | |
| 71 | 추가: } else { | |
| 72 | 추가: Format::Zip | |
| 73 | 추가: } | |
| 74 | 추가: }); | |
| 75 | 추가: self.frame(Event::ListEnd { | |
| 76 | 추가: entry_count: 1, | |
| 77 | 추가: list_id: ListId { | |
| 78 | 추가: catalog_version: 1, | |
| 79 | 추가: format, | |
| 80 | 추가: source_object: SourceObject::Unix { | |
| 81 | 추가: device: 1, | |
| 82 | 추가: inode: 1, | |
| 83 | 추가: }, | |
| 84 | 추가: archive_bytes: 54, | |
| 85 | 추가: archive_sha256: [7; 32], | |
| 86 | 추가: }, | |
| 87 | 추가: }); | |
| 88 | 추가: self.finish(Outcome::Completed, Publication::None); | |
| 89 | 추가: } | |
| 90 | 추가: _ => { | |
| 91 | 추가: self.frame(Event::Progress { | |
| 92 | 추가: stage: Stage::Write, | |
| 93 | 추가: processed: 31, | |
| 94 | 추가: total: Some(31), | |
| 95 | 추가: completed_entries: 1, | |
| 96 | 추가: }); | |
| 97 | 추가: self.frame(Event::Output { | |
| 98 | 추가: entry_id: Some(0), | |
| 99 | 추가: relative_name: "읽어주세요.txt".into(), | |
| 100 | 추가: disposition: Disposition::Created, | |
| 101 | 추가: }); | |
| 102 | 추가: self.finish(Outcome::Completed, Publication::Complete); | |
| 103 | 추가: } | |
| 104 | 추가: } | |
| 105 | 추가: } | |
| 106 | 추가: } | |
| 107 | 추가: struct FakeConnection { | |
| 108 | 추가: state: Rc<RefCell<State>>, | |
| 109 | 추가: } | |
| 110 | 추가: impl Drop for FakeConnection { | |
| 111 | 추가: fn drop(&mut self) { | |
| 112 | 추가: self.state.borrow_mut().dropped_connections += 1; | |
| 113 | 추가: } | |
| 114 | 추가: } | |
| 115 | 추가: impl Factory for FakeFactory { | |
| 116 | 추가: fn connect(&mut self, job: u64) -> Result<Box<dyn Connection>, String> { | |
| 117 | 추가: let mut s = self.state.borrow_mut(); | |
| 118 | 추가: s.job = job; | |
| 119 | 추가: s.sequence = 0; | |
| 120 | 추가: s.queue.clear(); | |
| 121 | 추가: s.pause = false; | |
| 122 | 추가: Ok(Box::new(FakeConnection { | |
| 123 | 추가: state: self.state.clone(), | |
| 124 | 추가: })) | |
| 125 | 추가: } | |
| 126 | 추가: } | |
| 127 | 추가: impl Connection for FakeConnection { | |
| 128 | 추가: fn send(&mut self, request: Request) -> Result<(), String> { | |
| 129 | 추가: let mut s = self.state.borrow_mut(); | |
| 130 | 추가: assert_eq!(s.job, request.job_id); | |
| 131 | 추가: match request.command { | |
| 132 | 추가: Command::Start(start) => { | |
| 133 | 추가: if let Start::Extract { | |
| 134 | 추가: list_id, | |
| 135 | 추가: gzip_output_name, | |
| 136 | 추가: .. | |
| 137 | 추가: } = &start | |
| 138 | 추가: { | |
| 139 | 추가: let valid = match list_id.format { | |
| 140 | 추가: Format::Gzip => gzip_output_name.as_deref().is_some_and(valid_leaf), | |
| 141 | 추가: _ => gzip_output_name.is_none(), | |
| 142 | 추가: }; | |
| 143 | 추가: if !valid { | |
| 144 | 추가: return Err("형식에 맞지 않는 GZIP 출력명".into()); | |
| 145 | 추가: } | |
| 146 | 추가: } | |
| 147 | 추가: s.requests.push((request.sequence, "start")); | |
| 148 | 추가: s.starts.push(start.clone()); | |
| 149 | 추가: if s.fail_start { | |
| 150 | 추가: return Err("Start 전송 실패".into()); | |
| 151 | 추가: } | |
| 152 | 추가: if !s.manual { | |
| 153 | 추가: s.frame(Event::Accepted { encryption: false }); | |
| 154 | 추가: s.frame(Event::Progress { | |
| 155 | 추가: stage: Stage::Scan, | |
| 156 | 추가: processed: 0, | |
| 157 | 추가: total: None, | |
| 158 | 추가: completed_entries: 0, | |
| 159 | 추가: }); | |
| 160 | 추가: if matches!(&start,Start::List {archive} if archive.file_name().is_some_and(|n|n.to_string_lossy().contains("locked"))) | |
| 161 | 추가: { | |
| 162 | 추가: s.frame(Event::PasswordRequired { | |
| 163 | 추가: challenge_id: 17, | |
| 164 | 추가: attempt: 1, | |
| 165 | 추가: encrypt: false, | |
| 166 | 추가: }); | |
| 167 | 추가: } else { | |
| 168 | 추가: s.complete_action(); | |
| 169 | 추가: } | |
| 170 | 추가: } | |
| 171 | 추가: } | |
| 172 | 추가: Command::Password { | |
| 173 | 추가: challenge_id, | |
| 174 | 추가: secret, | |
| 175 | 추가: } => { | |
| 176 | 추가: assert_eq!(challenge_id, 17); | |
| 177 | 추가: assert!(!secret.as_bytes().is_empty()); | |
| 178 | 추가: s.password_seen = true; | |
| 179 | 추가: s.requests.push((request.sequence, "password")); | |
| 180 | 추가: if !s.manual { | |
| 181 | 추가: s.complete_action(); | |
| 182 | 추가: } | |
| 183 | 추가: } | |
| 184 | 추가: Command::Cancel => { | |
| 185 | 추가: s.requests.push((request.sequence, "cancel")); | |
| 186 | 추가: if !s.manual { | |
| 187 | 추가: let consumed = s | |
| 188 | 추가: .queue | |
| 189 | 추가: .iter() | |
| 190 | 추가: .filter(|e| matches!(e, HostEvent::Frame { .. })) | |
| 191 | 추가: .count() as u64; | |
| 192 | 추가: s.sequence -= consumed; | |
| 193 | 추가: s.queue.clear(); | |
| 194 | 추가: s.frame(Event::CancelAck { | |
| 195 | 추가: request_sequence: request.sequence, | |
| 196 | 추가: status: CancelStatus::Requested, | |
| 197 | 추가: }); | |
| 198 | 추가: s.finish(Outcome::Cancelled, Publication::None); | |
| 199 | 추가: } | |
| 200 | 추가: } | |
| 201 | 추가: } | |
| 202 | 추가: Ok(()) | |
| 203 | 추가: } | |
| 204 | 추가: fn poll(&mut self) -> Option<HostEvent> { | |
| 205 | 추가: let mut s = self.state.borrow_mut(); | |
| 206 | 추가: if s.pause { | |
| 207 | 추가: s.pause = false; | |
| 208 | 추가: return None; | |
| 209 | 추가: } | |
| 210 | 추가: s.pause = true; | |
| 211 | 추가: s.queue.pop_front() | |
| 212 | 추가: } | |
| 213 | 추가: } |
| @@ -0,0 +1,64 @@ | ||
| 1 | 추가: import os | |
| 2 | 추가: from pathlib import Path | |
| 3 | 추가: import select | |
| 4 | 추가: import signal | |
| 5 | 추가: import subprocess | |
| 6 | 추가: import time | |
| 7 | 추가: | |
| 8 | 추가: | |
| 9 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 10 | 추가: OUTPUT = ROOT / "tests/rust-app-ui" / ("screens-" + str(time.time_ns())) | |
| 11 | 추가: | |
| 12 | 추가: | |
| 13 | 추가: def main(): | |
| 14 | 추가: OUTPUT.mkdir(exist_ok=True) | |
| 15 | 추가: display = subprocess.Popen( | |
| 16 | 추가: ["Xvfb", "-displayfd", "1", "-screen", "0", "1280x900x24", "-nolisten", "tcp"], | |
| 17 | 추가: stdout=subprocess.PIPE, stderr=subprocess.PIPE, start_new_session=True, | |
| 18 | 추가: ) | |
| 19 | 추가: app = None | |
| 20 | 추가: try: | |
| 21 | 추가: if not select.select([display.stdout], [], [], 15)[0]: | |
| 22 | 추가: raise RuntimeError("Xvfb 준비 시간 초과") | |
| 23 | 추가: number = display.stdout.readline().decode().strip() | |
| 24 | 추가: if not number.isdecimal(): | |
| 25 | 추가: raise RuntimeError("Xvfb display 응답 오류") | |
| 26 | 추가: env = {**os.environ, "DISPLAY": ":" + number, "WINIT_UNIX_BACKEND": "x11"} | |
| 27 | 추가: env.pop("WAYLAND_DISPLAY", None) | |
| 28 | 추가: with (OUTPUT / "app.stdout").open("wb") as stdout, (OUTPUT / "app.stderr").open("wb") as stderr: | |
| 29 | 추가: app = subprocess.Popen( | |
| 30 | 추가: [str(ROOT / "tests/ci/target/debug/zipelo-ui-memory-app"), "--ui-fixture", "/synthetic/example.zip"], | |
| 31 | 추가: env=env, stdout=stdout, stderr=stderr, start_new_session=True, | |
| 32 | 추가: ) | |
| 33 | 추가: deadline = time.monotonic() + 30 | |
| 34 | 추가: while True: | |
| 35 | 추가: if app.poll() is not None: | |
| 36 | 추가: raise RuntimeError(f"화면 조기 종료: {app.returncode}") | |
| 37 | 추가: window = subprocess.run(["xdotool", "search", "--all", "--pid", str(app.pid), "--name", "Zipelo"], env=env, timeout=5, capture_output=True) | |
| 38 | 추가: if window.returncode == 0: | |
| 39 | 추가: break | |
| 40 | 추가: if time.monotonic() >= deadline: | |
| 41 | 추가: raise RuntimeError("소유 창 표시 시간 초과") | |
| 42 | 추가: time.sleep(0.1) | |
| 43 | 추가: time.sleep(1) | |
| 44 | 추가: subprocess.run(["import", "-window", "root", str(OUTPUT / "list.png")], env=env, timeout=10, check=True) | |
| 45 | 추가: subprocess.run(["xdotool", "search", "--pid", str(app.pid), "--name", "Zipelo"], env=env, timeout=10, check=True) | |
| 46 | 추가: print(str(OUTPUT / "list.png")) | |
| 47 | 추가: finally: | |
| 48 | 추가: for process in [app, display]: | |
| 49 | 추가: if process is not None: | |
| 50 | 추가: if process.poll() is None: | |
| 51 | 추가: os.killpg(process.pid, signal.SIGTERM) | |
| 52 | 추가: try: | |
| 53 | 추가: process.wait(timeout=5) | |
| 54 | 추가: except subprocess.TimeoutExpired: | |
| 55 | 추가: os.killpg(process.pid, signal.SIGKILL) | |
| 56 | 추가: process.wait(timeout=5) | |
| 57 | 추가: if display.stdout: | |
| 58 | 추가: display.stdout.close() | |
| 59 | 추가: if display.stderr: | |
| 60 | 추가: display.stderr.close() | |
| 61 | 추가: | |
| 62 | 추가: | |
| 63 | 추가: if __name__ == "__main__": | |
| 64 | 추가: main() |
| @@ -0,0 +1,728 @@ | ||
| 1 | 추가: mod fake; | |
| 2 | 추가: use fake::*; | |
| 3 | 추가: use std::path::PathBuf; | |
| 4 | 추가: use zipelo_ui_memory_app::archive_ui::*; | |
| 5 | 추가: | |
| 6 | 추가: fn path(name: &str) -> PathBuf { | |
| 7 | 추가: std::env::current_dir().unwrap().join(name) | |
| 8 | 추가: } | |
| 9 | 추가: fn pump(m: &mut Model) { | |
| 10 | 추가: for _ in 0..100 { | |
| 11 | 추가: m.poll(); | |
| 12 | 추가: if !m.busy() { | |
| 13 | 추가: return; | |
| 14 | 추가: } | |
| 15 | 추가: } | |
| 16 | 추가: panic!("가짜 작업자 종료 누락: {}", m.status()); | |
| 17 | 추가: } | |
| 18 | 추가: fn list(m: &mut Model, f: &mut FakeFactory) { | |
| 19 | 추가: assert!(m.begin( | |
| 20 | 추가: Start::List { | |
| 21 | 추가: archive: path("example.zip") | |
| 22 | 추가: }, | |
| 23 | 추가: f | |
| 24 | 추가: )); | |
| 25 | 추가: pump(m); | |
| 26 | 추가: assert!(m.list_id.is_some()); | |
| 27 | 추가: } | |
| 28 | 추가: | |
| 29 | 추가: #[test] | |
| 30 | 추가: fn open_lists_only_after_terminal_eofs_and_wait() { | |
| 31 | 추가: let mut f = FakeFactory::default(); | |
| 32 | 추가: let mut m = Model::default(); | |
| 33 | 추가: assert!(m.begin( | |
| 34 | 추가: Start::List { | |
| 35 | 추가: archive: path("example.zip") | |
| 36 | 추가: }, | |
| 37 | 추가: &mut f | |
| 38 | 추가: )); | |
| 39 | 추가: while m.terminal.is_none() { | |
| 40 | 추가: m.poll(); | |
| 41 | 추가: assert!(m.list_id.is_none()); | |
| 42 | 추가: assert!(!m.can_extract()); | |
| 43 | 추가: } | |
| 44 | 추가: assert!(m.busy()); | |
| 45 | 추가: assert!(!m.begin( | |
| 46 | 추가: Start::List { | |
| 47 | 추가: archive: path("replacement.zip") | |
| 48 | 추가: }, | |
| 49 | 추가: &mut f | |
| 50 | 추가: )); | |
| 51 | 추가: pump(&mut m); | |
| 52 | 추가: assert_eq!(m.entries[0].name, "읽어주세요.txt"); | |
| 53 | 추가: assert!(m.can_extract()); | |
| 54 | 추가: assert!(m.confirmed); | |
| 55 | 추가: } | |
| 56 | 추가: #[test] | |
| 57 | 추가: fn extract_uses_list_token_selection_and_destination() { | |
| 58 | 추가: let mut f = FakeFactory::default(); | |
| 59 | 추가: let mut m = Model::default(); | |
| 60 | 추가: list(&mut m, &mut f); | |
| 61 | 추가: let token = m.list_id.clone().unwrap(); | |
| 62 | 추가: m.selected.insert(0); | |
| 63 | 추가: assert!(m.extract(path("output"), true, None, &mut f)); | |
| 64 | 추가: pump(&mut m); | |
| 65 | 추가: assert!( | |
| 66 | 추가: matches!(f.state.borrow().starts.last(),Some(Start::Extract {selection:Selection::EntryIds(ids),list_id,..}) if ids==&vec![0]&&*list_id==token) | |
| 67 | 추가: ); | |
| 68 | 추가: assert_eq!(m.terminal.unwrap().publication, Publication::Complete); | |
| 69 | 추가: } | |
| 70 | 추가: #[test] | |
| 71 | 추가: fn gzip_requires_explicit_leaf() { | |
| 72 | 추가: let mut f = FakeFactory::default(); | |
| 73 | 추가: let mut m = Model::default(); | |
| 74 | 추가: assert!(m.begin( | |
| 75 | 추가: Start::List { | |
| 76 | 추가: archive: path("sample.gz") | |
| 77 | 추가: }, | |
| 78 | 추가: &mut f | |
| 79 | 추가: )); | |
| 80 | 추가: pump(&mut m); | |
| 81 | 추가: for name in [None, Some("../escape".into()), Some("sub/file".into())] { | |
| 82 | 추가: assert!(!m.extract(path("output"), false, name, &mut f)); | |
| 83 | 추가: } | |
| 84 | 추가: assert!(m.extract(path("output"), false, Some("plain.txt".into()), &mut f)); | |
| 85 | 추가: pump(&mut m); | |
| 86 | 추가: } | |
| 87 | 추가: #[test] | |
| 88 | 추가: fn creates_zip_and_reports_progress_outputs() { | |
| 89 | 추가: let mut f = FakeFactory::default(); | |
| 90 | 추가: let mut m = Model::default(); | |
| 91 | 추가: assert!(m.begin( | |
| 92 | 추가: Start::CreateZip { | |
| 93 | 추가: sources: vec![(path("one.txt"), "one.txt".into())], | |
| 94 | 추가: output_file: path("new.zip"), | |
| 95 | 추가: method: Method::Deflate, | |
| 96 | 추가: aes256: false | |
| 97 | 추가: }, | |
| 98 | 추가: &mut f | |
| 99 | 추가: )); | |
| 100 | 추가: pump(&mut m); | |
| 101 | 추가: assert_eq!(m.progress.unwrap().1, 31); | |
| 102 | 추가: assert_eq!(m.outputs.len(), 1); | |
| 103 | 추가: assert_eq!(m.status(), "작업 완료"); | |
| 104 | 추가: } | |
| 105 | 추가: #[test] | |
| 106 | 추가: fn password_challenge_is_answered_without_retaining_secret() { | |
| 107 | 추가: let mut f = FakeFactory::default(); | |
| 108 | 추가: let mut m = Model::default(); | |
| 109 | 추가: assert!(m.begin( | |
| 110 | 추가: Start::List { | |
| 111 | 추가: archive: path("locked.zip") | |
| 112 | 추가: }, | |
| 113 | 추가: &mut f | |
| 114 | 추가: )); | |
| 115 | 추가: for _ in 0..10 { | |
| 116 | 추가: m.poll(); | |
| 117 | 추가: if m.challenge.is_some() { | |
| 118 | 추가: break; | |
| 119 | 추가: } | |
| 120 | 추가: } | |
| 121 | 추가: assert_eq!(m.challenge, Some((17, 1, false))); | |
| 122 | 추가: assert!(!m.password(String::new())); | |
| 123 | 추가: assert!(m.password("synthetic password".into())); | |
| 124 | 추가: pump(&mut m); | |
| 125 | 추가: assert!(f.state.borrow().password_seen); | |
| 126 | 추가: assert!(m.challenge.is_none()); | |
| 127 | 추가: assert!(m.list_id.is_some()); | |
| 128 | 추가: } | |
| 129 | 추가: #[test] | |
| 130 | 추가: fn cancel_close_retract_preserves_request_and_waits_for_exit() { | |
| 131 | 추가: let mut f = FakeFactory::default(); | |
| 132 | 추가: let mut m = Model::default(); | |
| 133 | 추가: assert!(m.begin( | |
| 134 | 추가: Start::List { | |
| 135 | 추가: archive: path("one.zip") | |
| 136 | 추가: }, | |
| 137 | 추가: &mut f | |
| 138 | 추가: )); | |
| 139 | 추가: m.poll(); | |
| 140 | 추가: m.request_close(); | |
| 141 | 추가: assert_eq!(m.close, Close::Confirm); | |
| 142 | 추가: m.confirm_close(); | |
| 143 | 추가: m.keep_open(); | |
| 144 | 추가: m.cancel(); | |
| 145 | 추가: pump(&mut m); | |
| 146 | 추가: assert_eq!(m.close, Close::Open); | |
| 147 | 추가: assert_eq!(m.cancel, Some(CancelStatus::Requested)); | |
| 148 | 추가: assert_eq!(m.terminal.unwrap().outcome, Outcome::Cancelled); | |
| 149 | 추가: assert_eq!( | |
| 150 | 추가: f.state | |
| 151 | 추가: .borrow() | |
| 152 | 추가: .requests | |
| 153 | 추가: .iter() | |
| 154 | 추가: .filter(|(_, k)| *k == "cancel") | |
| 155 | 추가: .count(), | |
| 156 | 추가: 1 | |
| 157 | 추가: ); | |
| 158 | 추가: } | |
| 159 | 추가: #[test] | |
| 160 | 추가: fn terminal_race_needs_no_cancel_ack() { | |
| 161 | 추가: let mut f = FakeFactory::manual(); | |
| 162 | 추가: let mut m = Model::default(); | |
| 163 | 추가: assert!(m.begin( | |
| 164 | 추가: Start::List { | |
| 165 | 추가: archive: path("one.zip") | |
| 166 | 추가: }, | |
| 167 | 추가: &mut f | |
| 168 | 추가: )); | |
| 169 | 추가: { | |
| 170 | 추가: let mut s = f.state.borrow_mut(); | |
| 171 | 추가: s.frame(Event::Accepted { encryption: false }); | |
| 172 | 추가: s.finish(Outcome::Cancelled, Publication::None); | |
| 173 | 추가: } | |
| 174 | 추가: m.cancel(); | |
| 175 | 추가: pump(&mut m); | |
| 176 | 추가: assert!(m.cancel.is_none()); | |
| 177 | 추가: assert_eq!(m.status(), "작업 취소됨"); | |
| 178 | 추가: } | |
| 179 | 추가: #[test] | |
| 180 | 추가: fn eof_exit_without_terminal_never_means_success() { | |
| 181 | 추가: let mut f = FakeFactory::manual(); | |
| 182 | 추가: let mut m = Model::default(); | |
| 183 | 추가: assert!(m.begin( | |
| 184 | 추가: Start::List { | |
| 185 | 추가: archive: path("one.zip") | |
| 186 | 추가: }, | |
| 187 | 추가: &mut f | |
| 188 | 추가: )); | |
| 189 | 추가: { | |
| 190 | 추가: let mut s = f.state.borrow_mut(); | |
| 191 | 추가: s.queue.extend([ | |
| 192 | 추가: HostEvent::StdoutEof, | |
| 193 | 추가: HostEvent::StderrEof, | |
| 194 | 추가: HostEvent::Exited { success: true }, | |
| 195 | 추가: ]); | |
| 196 | 추가: } | |
| 197 | 추가: pump(&mut m); | |
| 198 | 추가: assert!(!m.confirmed); | |
| 199 | 추가: assert!(m.list_id.is_none()); | |
| 200 | 추가: assert!(m.error.is_some()); | |
| 201 | 추가: } | |
| 202 | 추가: #[test] | |
| 203 | 추가: fn stale_sequence_and_job_are_protocol_errors() { | |
| 204 | 추가: for bad_job in [true, false] { | |
| 205 | 추가: let mut f = FakeFactory::manual(); | |
| 206 | 추가: let mut m = Model::default(); | |
| 207 | 추가: assert!(m.begin( | |
| 208 | 추가: Start::List { | |
| 209 | 추가: archive: path("one.zip") | |
| 210 | 추가: }, | |
| 211 | 추가: &mut f | |
| 212 | 추가: )); | |
| 213 | 추가: let id = m.job_id().unwrap(); | |
| 214 | 추가: f.state.borrow_mut().queue.push_back(HostEvent::Frame { | |
| 215 | 추가: job_id: if bad_job { id + 1 } else { id }, | |
| 216 | 추가: sequence: if bad_job { 0 } else { 1 }, | |
| 217 | 추가: event: Event::Accepted { encryption: false }, | |
| 218 | 추가: }); | |
| 219 | 추가: m.poll(); | |
| 220 | 추가: assert!(m.error.is_some()); | |
| 221 | 추가: assert!(m.busy()); | |
| 222 | 추가: } | |
| 223 | 추가: } | |
| 224 | 추가: #[test] | |
| 225 | 추가: fn source_changed_invalidates_selection_without_retry() { | |
| 226 | 추가: let mut f = FakeFactory::default(); | |
| 227 | 추가: let mut m = Model::default(); | |
| 228 | 추가: list(&mut m, &mut f); | |
| 229 | 추가: m.selected.insert(0); | |
| 230 | 추가: f.state.borrow_mut().manual = true; | |
| 231 | 추가: assert!(m.extract(path("out"), true, None, &mut f)); | |
| 232 | 추가: { | |
| 233 | 추가: let mut s = f.state.borrow_mut(); | |
| 234 | 추가: s.frame(Event::Accepted { encryption: false }); | |
| 235 | 추가: s.frame(Event::Terminal(Terminal { | |
| 236 | 추가: outcome: Outcome::Failed, | |
| 237 | 추가: error: Some(ErrorCode::SourceChanged), | |
| 238 | 추가: publication: Publication::None, | |
| 239 | 추가: created_count: 0, | |
| 240 | 추가: retained_partial_count: 0, | |
| 241 | 추가: durability: Durability::NotApplicable, | |
| 242 | 추가: cleanup: Cleanup::Complete, | |
| 243 | 추가: })); | |
| 244 | 추가: s.queue.extend([ | |
| 245 | 추가: HostEvent::StdoutEof, | |
| 246 | 추가: HostEvent::StderrEof, | |
| 247 | 추가: HostEvent::Exited { success: true }, | |
| 248 | 추가: ]); | |
| 249 | 추가: } | |
| 250 | 추가: pump(&mut m); | |
| 251 | 추가: assert!(m.list_id.is_none()); | |
| 252 | 추가: assert!(m.selected.is_empty()); | |
| 253 | 추가: assert_eq!(f.state.borrow().starts.len(), 2); | |
| 254 | 추가: } | |
| 255 | 추가: #[test] | |
| 256 | 추가: fn partial_and_uncertain_results_are_preserved() { | |
| 257 | 추가: let mut f = FakeFactory::manual(); | |
| 258 | 추가: let mut m = Model::default(); | |
| 259 | 추가: assert!(m.begin( | |
| 260 | 추가: Start::CreateZip { | |
| 261 | 추가: sources: vec![(path("one"), "one".into())], | |
| 262 | 추가: output_file: path("out.zip"), | |
| 263 | 추가: method: Method::Store, | |
| 264 | 추가: aes256: false | |
| 265 | 추가: }, | |
| 266 | 추가: &mut f | |
| 267 | 추가: )); | |
| 268 | 추가: { | |
| 269 | 추가: let mut s = f.state.borrow_mut(); | |
| 270 | 추가: s.frame(Event::Accepted { encryption: false }); | |
| 271 | 추가: s.frame(Event::Output { | |
| 272 | 추가: entry_id: None, | |
| 273 | 추가: relative_name: "out.zip".into(), | |
| 274 | 추가: disposition: Disposition::CommitUncertain, | |
| 275 | 추가: }); | |
| 276 | 추가: s.frame(Event::Terminal(Terminal { | |
| 277 | 추가: outcome: Outcome::Failed, | |
| 278 | 추가: error: Some(ErrorCode::Io), | |
| 279 | 추가: publication: Publication::Uncertain, | |
| 280 | 추가: created_count: 0, | |
| 281 | 추가: retained_partial_count: 1, | |
| 282 | 추가: durability: Durability::Failed, | |
| 283 | 추가: cleanup: Cleanup::Unconfirmed, | |
| 284 | 추가: })); | |
| 285 | 추가: s.queue.extend([ | |
| 286 | 추가: HostEvent::StdoutEof, | |
| 287 | 추가: HostEvent::StderrEof, | |
| 288 | 추가: HostEvent::Exited { success: true }, | |
| 289 | 추가: ]); | |
| 290 | 추가: } | |
| 291 | 추가: pump(&mut m); | |
| 292 | 추가: let t = m.terminal.as_ref().unwrap(); | |
| 293 | 추가: assert_eq!(t.publication, Publication::Uncertain); | |
| 294 | 추가: assert_eq!(t.retained_partial_count, 1); | |
| 295 | 추가: assert_eq!(t.durability, Durability::Failed); | |
| 296 | 추가: assert_eq!(m.outputs[0].1, Disposition::CommitUncertain); | |
| 297 | 추가: } | |
| 298 | 추가: #[test] | |
| 299 | 추가: fn close_requires_result_acknowledgement() { | |
| 300 | 추가: let mut f = FakeFactory::default(); | |
| 301 | 추가: let mut m = Model::default(); | |
| 302 | 추가: assert!(m.begin( | |
| 303 | 추가: Start::List { | |
| 304 | 추가: archive: path("one.zip") | |
| 305 | 추가: }, | |
| 306 | 추가: &mut f | |
| 307 | 추가: )); | |
| 308 | 추가: m.request_close(); | |
| 309 | 추가: m.confirm_close(); | |
| 310 | 추가: m.acknowledge_close(); | |
| 311 | 추가: assert_eq!(m.close, Close::Waiting); | |
| 312 | 추가: pump(&mut m); | |
| 313 | 추가: assert_eq!(m.close, Close::Review); | |
| 314 | 추가: m.acknowledge_close(); | |
| 315 | 추가: assert_eq!(m.close, Close::Allowed); | |
| 316 | 추가: } | |
| 317 | 추가: #[test] | |
| 318 | 추가: fn unsupported_worker_and_unsafe_inputs_do_not_start() { | |
| 319 | 추가: let mut m = Model::default(); | |
| 320 | 추가: assert!(!m.begin( | |
| 321 | 추가: Start::List { | |
| 322 | 추가: archive: path("one.zip") | |
| 323 | 추가: }, | |
| 324 | 추가: &mut Unavailable | |
| 325 | 추가: )); | |
| 326 | 추가: assert!(m.error.as_ref().unwrap().contains("준비")); | |
| 327 | 추가: let mut f = FakeFactory::default(); | |
| 328 | 추가: assert!(!m.begin( | |
| 329 | 추가: Start::List { | |
| 330 | 추가: archive: "relative.zip".into() | |
| 331 | 추가: }, | |
| 332 | 추가: &mut f | |
| 333 | 추가: )); | |
| 334 | 추가: assert!(!m.begin( | |
| 335 | 추가: Start::CreateZip { | |
| 336 | 추가: sources: vec![(path("one"), "../one".into())], | |
| 337 | 추가: output_file: path("out.zip"), | |
| 338 | 추가: method: Method::Store, | |
| 339 | 추가: aes256: false | |
| 340 | 추가: }, | |
| 341 | 추가: &mut f | |
| 342 | 추가: )); | |
| 343 | 추가: assert!(f.state.borrow().starts.is_empty()); | |
| 344 | 추가: } | |
| 345 | 추가: #[cfg(feature = "ui")] | |
| 346 | 추가: #[test] | |
| 347 | 추가: fn renders_every_flow_with_actual_egui_widgets() { | |
| 348 | 추가: use eframe::egui::{self, epaint::Shape}; | |
| 349 | 추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp; | |
| 350 | 추가: fn text(shapes: &[egui::epaint::ClippedShape]) -> Vec<(String, egui::Pos2)> { | |
| 351 | 추가: fn walk(shape: &Shape, result: &mut Vec<(String, egui::Pos2)>) { | |
| 352 | 추가: match shape { | |
| 353 | 추가: Shape::Text(t) => result.push(( | |
| 354 | 추가: t.galley.job.text.clone(), | |
| 355 | 추가: t.pos + t.galley.rect.size() / 2.0, | |
| 356 | 추가: )), | |
| 357 | 추가: Shape::Vec(v) => { | |
| 358 | 추가: for shape in v { | |
| 359 | 추가: walk(shape, result); | |
| 360 | 추가: } | |
| 361 | 추가: } | |
| 362 | 추가: _ => {} | |
| 363 | 추가: } | |
| 364 | 추가: } | |
| 365 | 추가: let mut result = Vec::new(); | |
| 366 | 추가: for shape in shapes { | |
| 367 | 추가: walk(&shape.shape, &mut result); | |
| 368 | 추가: } | |
| 369 | 추가: result | |
| 370 | 추가: } | |
| 371 | 추가: let ctx = egui::Context::default(); | |
| 372 | 추가: let f = FakeFactory::default(); | |
| 373 | 추가: let mut app = ArchiveApp::new(Box::new(f.clone()), None, true); | |
| 374 | 추가: let render = |app: &mut ArchiveApp, events: Vec<egui::Event>, width: f32| { | |
| 375 | 추가: let mut output = ctx.run_ui( | |
| 376 | 추가: egui::RawInput { | |
| 377 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 378 | 추가: egui::Pos2::ZERO, | |
| 379 | 추가: egui::vec2(width, 720.0), | |
| 380 | 추가: )), | |
| 381 | 추가: events, | |
| 382 | 추가: ..Default::default() | |
| 383 | 추가: }, | |
| 384 | 추가: |ui| app.show(ui), | |
| 385 | 추가: ); | |
| 386 | 추가: output.textures_delta.clear(); | |
| 387 | 추가: assert!(!output.shapes.is_empty()); | |
| 388 | 추가: text(&output.shapes) | |
| 389 | 추가: }; | |
| 390 | 추가: let initial = render(&mut app, vec![], 1060.0); | |
| 391 | 추가: let point = initial.iter().find(|(t, _)| t == "ZIP 만들기").unwrap().1; | |
| 392 | 추가: render( | |
| 393 | 추가: &mut app, | |
| 394 | 추가: vec![ | |
| 395 | 추가: egui::Event::PointerMoved(point), | |
| 396 | 추가: egui::Event::PointerButton { | |
| 397 | 추가: pos: point, | |
| 398 | 추가: button: egui::PointerButton::Primary, | |
| 399 | 추가: pressed: true, | |
| 400 | 추가: modifiers: egui::Modifiers::default(), | |
| 401 | 추가: }, | |
| 402 | 추가: ], | |
| 403 | 추가: 1060.0, | |
| 404 | 추가: ); | |
| 405 | 추가: render( | |
| 406 | 추가: &mut app, | |
| 407 | 추가: vec![egui::Event::PointerButton { | |
| 408 | 추가: pos: point, | |
| 409 | 추가: button: egui::PointerButton::Primary, | |
| 410 | 추가: pressed: false, | |
| 411 | 추가: modifiers: egui::Modifiers::default(), | |
| 412 | 추가: }], | |
| 413 | 추가: 1060.0, | |
| 414 | 추가: ); | |
| 415 | 추가: let create = render(&mut app, vec![], 1060.0); | |
| 416 | 추가: assert!(create.iter().any(|(t, _)| t == "저장할 ZIP 절대 경로")); | |
| 417 | 추가: let mut app = ArchiveApp::new(Box::new(f.clone()), Some(path("locked.zip")), true); | |
| 418 | 추가: for _ in 0..8 { | |
| 419 | 추가: app.model.poll(); | |
| 420 | 추가: } | |
| 421 | 추가: for width in [760.0, 1060.0] { | |
| 422 | 추가: render(&mut app, vec![], width); | |
| 423 | 추가: render(&mut app, vec![], width); | |
| 424 | 추가: let password = render(&mut app, vec![], width); | |
| 425 | 추가: assert!(password.iter().any(|(t, _)| t.contains("암호 전달"))); | |
| 426 | 추가: } | |
| 427 | 추가: assert!(app.model.password("synthetic secret".into())); | |
| 428 | 추가: pump(&mut app.model); | |
| 429 | 추가: let listed = render(&mut app, vec![], 1060.0); | |
| 430 | 추가: assert!(listed.iter().any(|(t, _)| t == "읽어주세요.txt")); | |
| 431 | 추가: assert!(!listed.iter().any(|(t, _)| t.contains("synthetic secret"))); | |
| 432 | 추가: assert!(app.model.extract(path("out"), false, None, &mut f.clone())); | |
| 433 | 추가: render(&mut app, vec![], 1060.0); | |
| 434 | 추가: app.model.request_close(); | |
| 435 | 추가: render(&mut app, vec![], 1060.0); | |
| 436 | 추가: let confirm = render(&mut app, vec![], 1060.0); | |
| 437 | 추가: assert!(confirm.iter().any(|(t, _)| t == "작업 중 닫기")); | |
| 438 | 추가: app.model.confirm_close(); | |
| 439 | 추가: pump(&mut app.model); | |
| 440 | 추가: render(&mut app, vec![], 1060.0); | |
| 441 | 추가: let result = render(&mut app, vec![], 1060.0); | |
| 442 | 추가: assert!(result.iter().any(|(t, _)| t == "결과 확인 후 닫기")); | |
| 443 | 추가: } | |
| 444 | 추가: | |
| 445 | 추가: #[test] | |
| 446 | 추가: fn file_association_arguments_preserve_native_paths() { | |
| 447 | 추가: let cwd = std::env::current_dir().unwrap(); | |
| 448 | 추가: let (fixture, archive) = | |
| 449 | 추가: launch_args(vec!["--ui-fixture".into(), "한글.zip".into()], cwd.clone()).unwrap(); | |
| 450 | 추가: assert!(fixture); | |
| 451 | 추가: assert_eq!(archive, Some(cwd.join("한글.zip"))); | |
| 452 | 추가: assert!(launch_args(vec!["a".into(), "b".into()], cwd.clone()).is_err()); | |
| 453 | 추가: #[cfg(unix)] | |
| 454 | 추가: { | |
| 455 | 추가: use std::os::unix::ffi::OsStringExt; | |
| 456 | 추가: let name = std::ffi::OsString::from_vec(vec![b'/', 0xff, b'a']); | |
| 457 | 추가: assert_eq!( | |
| 458 | 추가: launch_args(vec![name.clone()], cwd).unwrap().1, | |
| 459 | 추가: Some(PathBuf::from(name)) | |
| 460 | 추가: ); | |
| 461 | 추가: } | |
| 462 | 추가: } | |
| 463 | 추가: | |
| 464 | 추가: #[cfg(feature = "ui")] | |
| 465 | 추가: #[test] | |
| 466 | 추가: fn dropped_native_file_opens_without_ui_reading_contents() { | |
| 467 | 추가: use eframe::egui; | |
| 468 | 추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp; | |
| 469 | 추가: #[derive(Debug)] | |
| 470 | 추가: struct DropFile(PathBuf); | |
| 471 | 추가: impl egui::DroppedFile for DropFile { | |
| 472 | 추가: fn path(&self) -> &std::path::Path { | |
| 473 | 추가: &self.0 | |
| 474 | 추가: } | |
| 475 | 추가: fn bytes(&self) -> Result<Vec<u8>, String> { | |
| 476 | 추가: panic!("화면이 압축파일을 직접 읽으면 안 됨") | |
| 477 | 추가: } | |
| 478 | 추가: } | |
| 479 | 추가: let ctx = egui::Context::default(); | |
| 480 | 추가: let f = FakeFactory::default(); | |
| 481 | 추가: let mut app = ArchiveApp::new(Box::new(f.clone()), None, true); | |
| 482 | 추가: let file = path("dropped.zip"); | |
| 483 | 추가: let mut output = ctx.run_ui( | |
| 484 | 추가: egui::RawInput { | |
| 485 | 추가: dropped_files: vec![std::sync::Arc::new(DropFile(file.clone()))], | |
| 486 | 추가: ..Default::default() | |
| 487 | 추가: }, | |
| 488 | 추가: |ui| app.show(ui), | |
| 489 | 추가: ); | |
| 490 | 추가: output.textures_delta.clear(); | |
| 491 | 추가: assert_eq!(app.model.archive, Some(file)); | |
| 492 | 추가: assert_eq!(f.state.borrow().starts.len(), 1); | |
| 493 | 추가: pump(&mut app.model); | |
| 494 | 추가: assert!(app.model.can_extract()); | |
| 495 | 추가: } | |
| 496 | 추가: | |
| 497 | 추가: #[test] | |
| 498 | 추가: fn failed_start_retains_connection_until_both_eofs_and_child_wait() { | |
| 499 | 추가: for missing in 0..3 { | |
| 500 | 추가: let mut factory = FakeFactory::manual(); | |
| 501 | 추가: factory.state.borrow_mut().fail_start = true; | |
| 502 | 추가: let mut model = Model::default(); | |
| 503 | 추가: assert!(!model.begin( | |
| 504 | 추가: Start::List { | |
| 505 | 추가: archive: path("failed.zip") | |
| 506 | 추가: }, | |
| 507 | 추가: &mut factory | |
| 508 | 추가: )); | |
| 509 | 추가: assert!(model.busy()); | |
| 510 | 추가: assert_eq!(factory.state.borrow().dropped_connections, 0); | |
| 511 | 추가: assert_eq!(model.job_id(), Some(1)); | |
| 512 | 추가: model.request_close(); | |
| 513 | 추가: model.confirm_close(); | |
| 514 | 추가: assert_eq!(model.close, Close::Waiting); | |
| 515 | 추가: assert_eq!(factory.state.borrow().requests, vec![(0, "start")]); | |
| 516 | 추가: let event = |index| match index { | |
| 517 | 추가: 0 => HostEvent::StdoutEof, | |
| 518 | 추가: 1 => HostEvent::StderrEof, | |
| 519 | 추가: _ => HostEvent::Exited { success: false }, | |
| 520 | 추가: }; | |
| 521 | 추가: for index in 0..3 { | |
| 522 | 추가: if index != missing { | |
| 523 | 추가: factory.state.borrow_mut().queue.push_back(event(index)); | |
| 524 | 추가: } | |
| 525 | 추가: } | |
| 526 | 추가: for _ in 0..20 { | |
| 527 | 추가: model.poll(); | |
| 528 | 추가: } | |
| 529 | 추가: assert!(model.busy()); | |
| 530 | 추가: assert!(!model.can_extract()); | |
| 531 | 추가: assert_eq!(factory.state.borrow().dropped_connections, 0); | |
| 532 | 추가: model.acknowledge_close(); | |
| 533 | 추가: assert_eq!(model.close, Close::Waiting); | |
| 534 | 추가: assert!(!model.begin( | |
| 535 | 추가: Start::List { | |
| 536 | 추가: archive: path("replacement.zip") | |
| 537 | 추가: }, | |
| 538 | 추가: &mut factory | |
| 539 | 추가: )); | |
| 540 | 추가: factory.state.borrow_mut().queue.push_back(event(missing)); | |
| 541 | 추가: pump(&mut model); | |
| 542 | 추가: assert!(!model.confirmed); | |
| 543 | 추가: assert!(model.terminal.is_none()); | |
| 544 | 추가: assert_eq!(model.error.as_deref(), Some("Start 전송 실패")); | |
| 545 | 추가: assert_eq!(factory.state.borrow().dropped_connections, 1); | |
| 546 | 추가: assert_eq!(model.close, Close::Review); | |
| 547 | 추가: if missing == 0 { | |
| 548 | 추가: model.acknowledge_close(); | |
| 549 | 추가: assert_eq!(model.close, Close::Allowed); | |
| 550 | 추가: } else { | |
| 551 | 추가: model.keep_open(); | |
| 552 | 추가: factory.state.borrow_mut().fail_start = false; | |
| 553 | 추가: assert!(model.begin( | |
| 554 | 추가: Start::List { | |
| 555 | 추가: archive: path("replacement.zip") | |
| 556 | 추가: }, | |
| 557 | 추가: &mut factory | |
| 558 | 추가: )); | |
| 559 | 추가: assert_eq!(model.job_id(), Some(2)); | |
| 560 | 추가: } | |
| 561 | 추가: } | |
| 562 | 추가: } | |
| 563 | 추가: | |
| 564 | 추가: #[test] | |
| 565 | 추가: fn non_gzip_formats_reject_a_gzip_output_name_before_connect() { | |
| 566 | 추가: for format in [Format::Zip, Format::Tar, Format::TarGzip] { | |
| 567 | 추가: let mut factory = FakeFactory::default(); | |
| 568 | 추가: factory.state.borrow_mut().list_format = Some(format); | |
| 569 | 추가: let mut model = Model::default(); | |
| 570 | 추가: list(&mut model, &mut factory); | |
| 571 | 추가: let count = factory.state.borrow().starts.len(); | |
| 572 | 추가: assert!(!model.extract(path("out"), false, Some("stale.txt".into()), &mut factory)); | |
| 573 | 추가: assert!(!model.busy()); | |
| 574 | 추가: assert_eq!(factory.state.borrow().starts.len(), count); | |
| 575 | 추가: assert!(model.extract(path("out"), false, None, &mut factory)); | |
| 576 | 추가: pump(&mut model); | |
| 577 | 추가: } | |
| 578 | 추가: } | |
| 579 | 추가: | |
| 580 | 추가: #[cfg(feature = "ui")] | |
| 581 | 추가: #[test] | |
| 582 | 추가: fn extract_button_sends_gzip_name_only_for_raw_gzip() { | |
| 583 | 추가: use eframe::egui::{self, epaint::Shape}; | |
| 584 | 추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp; | |
| 585 | 추가: for format in [Format::Zip, Format::Tar, Format::TarGzip, Format::Gzip] { | |
| 586 | 추가: let ctx = egui::Context::default(); | |
| 587 | 추가: let factory = FakeFactory::default(); | |
| 588 | 추가: factory.state.borrow_mut().list_format = Some(format); | |
| 589 | 추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), Some(path("input.archive")), true); | |
| 590 | 추가: pump(&mut app.model); | |
| 591 | 추가: let render = |app: &mut ArchiveApp, events| { | |
| 592 | 추가: fn walk(shape: &Shape, output: &mut Vec<(String, egui::Pos2)>) { | |
| 593 | 추가: match shape { | |
| 594 | 추가: Shape::Text(text) => output.push(( | |
| 595 | 추가: text.galley.job.text.clone(), | |
| 596 | 추가: text.pos + text.galley.rect.size() / 2.0, | |
| 597 | 추가: )), | |
| 598 | 추가: Shape::Vec(shapes) => { | |
| 599 | 추가: for shape in shapes { | |
| 600 | 추가: walk(shape, output); | |
| 601 | 추가: } | |
| 602 | 추가: } | |
| 603 | 추가: _ => {} | |
| 604 | 추가: } | |
| 605 | 추가: } | |
| 606 | 추가: let mut frame = ctx.run_ui( | |
| 607 | 추가: egui::RawInput { | |
| 608 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 609 | 추가: egui::Pos2::ZERO, | |
| 610 | 추가: egui::vec2(1060.0, 720.0), | |
| 611 | 추가: )), | |
| 612 | 추가: events, | |
| 613 | 추가: ..Default::default() | |
| 614 | 추가: }, | |
| 615 | 추가: |ui| app.show(ui), | |
| 616 | 추가: ); | |
| 617 | 추가: frame.textures_delta.clear(); | |
| 618 | 추가: let mut output = Vec::new(); | |
| 619 | 추가: for shape in frame.shapes { | |
| 620 | 추가: walk(&shape.shape, &mut output); | |
| 621 | 추가: } | |
| 622 | 추가: output | |
| 623 | 추가: }; | |
| 624 | 추가: let click = |app: &mut ArchiveApp, point| { | |
| 625 | 추가: render( | |
| 626 | 추가: app, | |
| 627 | 추가: vec![ | |
| 628 | 추가: egui::Event::PointerMoved(point), | |
| 629 | 추가: egui::Event::PointerButton { | |
| 630 | 추가: pos: point, | |
| 631 | 추가: button: egui::PointerButton::Primary, | |
| 632 | 추가: pressed: true, | |
| 633 | 추가: modifiers: Default::default(), | |
| 634 | 추가: }, | |
| 635 | 추가: ], | |
| 636 | 추가: ); | |
| 637 | 추가: render( | |
| 638 | 추가: app, | |
| 639 | 추가: vec![egui::Event::PointerButton { | |
| 640 | 추가: pos: point, | |
| 641 | 추가: button: egui::PointerButton::Primary, | |
| 642 | 추가: pressed: false, | |
| 643 | 추가: modifiers: Default::default(), | |
| 644 | 추가: }], | |
| 645 | 추가: ); | |
| 646 | 추가: }; | |
| 647 | 추가: render(&mut app, vec![]); | |
| 648 | 추가: let texts = render(&mut app, vec![]); | |
| 649 | 추가: let folder = texts | |
| 650 | 추가: .iter() | |
| 651 | 추가: .find(|(text, _)| text == "출력 폴더") | |
| 652 | 추가: .unwrap() | |
| 653 | 추가: .1; | |
| 654 | 추가: click(&mut app, folder + egui::vec2(100.0, 0.0)); | |
| 655 | 추가: render( | |
| 656 | 추가: &mut app, | |
| 657 | 추가: vec![egui::Event::Text( | |
| 658 | 추가: path("button-output").to_string_lossy().into_owned(), | |
| 659 | 추가: )], | |
| 660 | 추가: ); | |
| 661 | 추가: if format == Format::Gzip { | |
| 662 | 추가: let texts = render(&mut app, vec![]); | |
| 663 | 추가: let name = texts | |
| 664 | 추가: .iter() | |
| 665 | 추가: .find(|(text, _)| text == "출력 파일명") | |
| 666 | 추가: .unwrap() | |
| 667 | 추가: .1; | |
| 668 | 추가: click(&mut app, name + egui::vec2(100.0, 0.0)); | |
| 669 | 추가: render(&mut app, vec![egui::Event::Text("plain.txt".into())]); | |
| 670 | 추가: } | |
| 671 | 추가: let texts = render(&mut app, vec![]); | |
| 672 | 추가: let button = texts.iter().find(|(text, _)| text == "풀기").unwrap().1; | |
| 673 | 추가: click(&mut app, button); | |
| 674 | 추가: let state = factory.state.borrow(); | |
| 675 | 추가: assert_eq!( | |
| 676 | 추가: state.starts.len(), | |
| 677 | 추가: 2, | |
| 678 | 추가: "풀기 버튼의 Start 요청 누락: {format:?}" | |
| 679 | 추가: ); | |
| 680 | 추가: match state.starts.last().unwrap() { | |
| 681 | 추가: Start::Extract { | |
| 682 | 추가: gzip_output_name, .. | |
| 683 | 추가: } => assert_eq!( | |
| 684 | 추가: gzip_output_name, | |
| 685 | 추가: &if format == Format::Gzip { | |
| 686 | 추가: Some("plain.txt".into()) | |
| 687 | 추가: } else { | |
| 688 | 추가: None | |
| 689 | 추가: } | |
| 690 | 추가: ), | |
| 691 | 추가: _ => panic!("Extract 요청 누락"), | |
| 692 | 추가: } | |
| 693 | 추가: } | |
| 694 | 추가: } | |
| 695 | 추가: | |
| 696 | 추가: #[test] | |
| 697 | 추가: fn fake_worker_rejects_invalid_format_specific_output_names() { | |
| 698 | 추가: for (format, name) in [ | |
| 699 | 추가: (Format::Zip, Some("stale.txt".into())), | |
| 700 | 추가: (Format::Tar, Some(String::new())), | |
| 701 | 추가: (Format::TarGzip, Some("stale.txt".into())), | |
| 702 | 추가: (Format::Gzip, None), | |
| 703 | 추가: (Format::Gzip, Some("../escape".into())), | |
| 704 | 추가: ] { | |
| 705 | 추가: let mut factory = FakeFactory::default(); | |
| 706 | 추가: factory.state.borrow_mut().list_format = Some(format); | |
| 707 | 추가: let mut model = Model::default(); | |
| 708 | 추가: list(&mut model, &mut factory); | |
| 709 | 추가: let mut connection = factory.connect(2).unwrap(); | |
| 710 | 추가: let previous = factory.state.borrow().starts.len(); | |
| 711 | 추가: assert!( | |
| 712 | 추가: connection | |
| 713 | 추가: .send(Request { | |
| 714 | 추가: job_id: 2, | |
| 715 | 추가: sequence: 0, | |
| 716 | 추가: command: Command::Start(Start::Extract { | |
| 717 | 추가: archive: model.archive.clone().unwrap(), | |
| 718 | 추가: destination: path("output"), | |
| 719 | 추가: selection: Selection::All, | |
| 720 | 추가: list_id: model.list_id.clone().unwrap(), | |
| 721 | 추가: gzip_output_name: name, | |
| 722 | 추가: }), | |
| 723 | 추가: }) | |
| 724 | 추가: .is_err() | |
| 725 | 추가: ); | |
| 726 | 추가: assert_eq!(factory.state.borrow().starts.len(), previous); | |
| 727 | 추가: } | |
| 728 | 추가: } |
| @@ -0,0 +1,66 @@ | ||
| 1 | 추가: { | |
| 2 | 추가: "command": "python3 tests/ci/run_rust.py local", | |
| 3 | 추가: "platform": "linux-desktop-2", | |
| 4 | 추가: "base_remote_main": "486fe9ae64a73f999cc5122c2eb9bbeb62fb2fb3", | |
| 5 | 추가: "local_baseline_head": "6ea0b8b3b7444c35bb0845b58bf5638ac58f5e58", | |
| 6 | 추가: "source_state": "Committed frontend review fixes over the existing local baseline whose tree equals remote main. Tested file hashes identify the reviewed implementation.", | |
| 7 | 추가: "linux_build_crates": 17, | |
| 8 | 추가: "linux_test_targets": 17, | |
| 9 | 추가: "rust_tests_passed": 827, | |
| 10 | 추가: "new_archive_ui_tests_passed": 20, | |
| 11 | 추가: "windows_cross_build_crates": 17, | |
| 12 | 추가: "windows_runtime_tested": false, | |
| 13 | 추가: "native_visual_check": "Owned Xvfb screen displayed Korean synthetic file list; initial capture missed Xvfb because inherited Wayland selected host backend; corrected capture removes Wayland only in owned process environment. Not complete native interaction coverage.", | |
| 14 | 추가: "prior_failures": "Retained locally: first build drop API/legacy harness references; second and third egui renderer harness texture/first-frame setup; final runner passed.", | |
| 15 | 추가: "limitations": [ | |
| 16 | 추가: "Fake transport projects agreed revision2 semantics; no binary codec, actual worker process, filesystem extraction or encryption in this frontend PR.", | |
| 17 | 추가: "Default executable explicitly reports unavailable worker. ui-fixture feature AND --ui-fixture flag select test-only fake; UI labels it.", | |
| 18 | 추가: "Entry listing is metadata, not integrity proof. Partial publication/durability/cleanup remain separate.", | |
| 19 | 추가: "UTF-8 text fields for manual paths; native CLI/drop archive paths stay PathBuf. ZIP multi-source manual entry is UTF-8 only." | |
| 20 | 추가: ], | |
| 21 | 추가: "tested_files": [ | |
| 22 | 추가: { | |
| 23 | 추가: "path": "experiments/rust-ui-memory-app/Cargo.toml", | |
| 24 | 추가: "sha256": "1b161c74260b64de926b37528d61fd73de4074d250f711d8458ed770c0af69d8" | |
| 25 | 추가: }, | |
| 26 | 추가: { | |
| 27 | 추가: "path": "experiments/rust-ui-memory-app/src/lib.rs", | |
| 28 | 추가: "sha256": "335104e14b4fd69fd20e29941a1cc40c7c123bd7b853c09206c39d10b55fda2c" | |
| 29 | 추가: }, | |
| 30 | 추가: { | |
| 31 | 추가: "path": "experiments/rust-ui-memory-app/src/desktop.rs", | |
| 32 | 추가: "sha256": "5d0e14f72cdebc6fe02952539db55c682cb5978fd883e072bd08d461807c8106" | |
| 33 | 추가: }, | |
| 34 | 추가: { | |
| 35 | 추가: "path": "experiments/rust-ui-memory-app/src/archive_ui.rs", | |
| 36 | 추가: "sha256": "f06fd50c557e178cb5cb98cb39e3ba5e04088a774f60ec92774bc37ed3323b87" | |
| 37 | 추가: }, | |
| 38 | 추가: { | |
| 39 | 추가: "path": "experiments/rust-ui-memory-app/src/archive_screen.rs", | |
| 40 | 추가: "sha256": "04b7a55c7405d89467fc821db27e0714fb0aa00612e614835b5fee901e5ca940" | |
| 41 | 추가: }, | |
| 42 | 추가: { | |
| 43 | 추가: "path": "tests/rust-app-ui/regressions.rs", | |
| 44 | 추가: "sha256": "461e9a36bc5b742bf523fe0f1bfb7900c1b97a884e3e8f6040f85fe474efdf4e" | |
| 45 | 추가: }, | |
| 46 | 추가: { | |
| 47 | 추가: "path": "tests/rust-app-ui/fake.rs", | |
| 48 | 추가: "sha256": "f0d7fc88a1399f12f95aa045c2c55e3ff2d8057625a6d615d88f9bee10a36b51" | |
| 49 | 추가: }, | |
| 50 | 추가: { | |
| 51 | 추가: "path": "tests/rust-app-ui/native_smoke.py", | |
| 52 | 추가: "sha256": "303cff6a9452b43db62af21ad906aef49279f7bf23136e2166793d4118d951dc" | |
| 53 | 추가: }, | |
| 54 | 추가: { | |
| 55 | 추가: "path": "tests/rust-app-ui/README.md", | |
| 56 | 추가: "sha256": "942e108820d43ba9a70ba013cd7f1683d8bb90699315bda179ca95c4a15a736e" | |
| 57 | 추가: } | |
| 58 | 추가: ], | |
| 59 | 추가: "review_regressions": [ | |
| 60 | 추가: "실제 풀기 버튼의 ZIP/TAR/TAR.GZ/GZIP 출력명 계약", | |
| 61 | 추가: "비 GZIP 출력명 요청의 연결 전 거부", | |
| 62 | 추가: "가짜 작업자의 형식별 출력명 검증", | |
| 63 | 추가: "Start 전송 실패 시 양쪽 EOF/child wait까지 연결 보존과 닫기/교체 차단" | |
| 64 | 추가: ], | |
| 65 | 추가: "before_review_fix": "Targeted regressions reproduced 3 failures with 16 existing tests passing before the product fix; final targeted suite passed 20 tests." | |
| 66 | 추가: } |