자동 풀 위치 권한과 완료 안내를 수정함
- 작성자
- 호시노 히나타
- 작성 시각
- 커밋
0c96f094ea9b30e30f3786272c0cee282f87518b- 부모
- 495b855
변경된 파일 4개
+171-3| @@ -86,7 +86,13 @@ pub fn prepare_destination(path: &Path, automatic: bool) -> io::Result<bool> { | ||
| 86 | 86 | Ok(metadata) if metadata.is_dir() && !metadata.file_type().is_symlink() => Ok(false), |
| 87 | 87 | Ok(_) => Err(io::Error::other(FOLDER_ERROR)), |
| 88 | 88 | Err(error) if error.kind() == io::ErrorKind::NotFound && automatic => { |
| 89 | 삭제: fs::create_dir(path)?; | |
| 89 | 추가: let mut builder = fs::DirBuilder::new(); | |
| 90 | 추가: #[cfg(unix)] | |
| 91 | 추가: { | |
| 92 | 추가: use std::os::unix::fs::DirBuilderExt; | |
| 93 | 추가: builder.mode(0o700); | |
| 94 | 추가: } | |
| 95 | 추가: builder.create(path)?; | |
| 90 | 96 | Ok(true) |
| 91 | 97 | } |
| 92 | 98 | Err(error) => Err(error), |
| @@ -864,7 +864,9 @@ impl ArchiveApp { | ||
| 864 | 864 | let success = self.model.confirmed |
| 865 | 865 | && self.model.error.is_none() |
| 866 | 866 | && t.as_ref().is_some_and(|t| t.outcome == Outcome::Completed) |
| 867 | 삭제: && warnings.is_empty(); | |
| 867 | 추가: && warnings | |
| 868 | 추가: .iter() | |
| 869 | 추가: .all(|warning| *warning == present::SYNC_WARNING); | |
| 868 | 870 | let cancelled = |
| 869 | 871 | self.model.confirmed && t.as_ref().is_some_and(|t| t.outcome == Outcome::Cancelled); |
| 870 | 872 | let title = if success { |
| @@ -929,7 +931,10 @@ impl ArchiveApp { | ||
| 929 | 931 | } else if let Some(error) = &self.model.error { |
| 930 | 932 | ui.label(present::client_error_text(error)); |
| 931 | 933 | } |
| 932 | 삭제: for warning in &warnings { | |
| 934 | 추가: for warning in warnings | |
| 935 | 추가: .iter() | |
| 936 | 추가: .filter(|warning| **warning != present::SYNC_WARNING) | |
| 937 | 추가: { | |
| 933 | 938 | ui.horizontal_wrapped(|ui| { |
| 934 | 939 | theme::icon(ui, Icon::Warning, 20.0); |
| 935 | 940 | ui.colored_label(theme::WARNING, *warning); |
| @@ -947,6 +952,9 @@ impl ArchiveApp { | ||
| 947 | 952 | } |
| 948 | 953 | if self.details { |
| 949 | 954 | theme::panel(theme::STRIPE).show(ui, |ui| { |
| 955 | 추가: if warnings.contains(&present::SYNC_WARNING) { | |
| 956 | 추가: ui.label(present::SYNC_WARNING); | |
| 957 | 추가: } | |
| 950 | 958 | if let Some(t) = &t { |
| 951 | 959 | for line in terminal_lines(t) { |
| 952 | 960 | ui.label(line); |
| @@ -146,3 +146,73 @@ fn extraction_completion_matches_actual_worker_selection_matrix() { | ||
| 146 | 146 | } |
| 147 | 147 | assert_reaped(&observed); |
| 148 | 148 | } |
| 149 | 추가: | |
| 150 | 추가: #[cfg(unix)] | |
| 151 | 추가: #[test] | |
| 152 | 추가: fn auto_destination_is_private_under_desktop_umask() { | |
| 153 | 추가: use std::{os::unix::fs::PermissionsExt, process::Command}; | |
| 154 | 추가: | |
| 155 | 추가: const CHILD: &str = "ZIPELO_PRIVATE_DESTINATION_CHILD"; | |
| 156 | 추가: if std::env::var_os(CHILD).is_none() { | |
| 157 | 추가: let output = Command::new("sh") | |
| 158 | 추가: .args([ | |
| 159 | 추가: "-c", | |
| 160 | 추가: "umask 0002; exec \"$@\"", | |
| 161 | 추가: "zipelo-private-destination", | |
| 162 | 추가: ]) | |
| 163 | 추가: .arg(std::env::current_exe().unwrap()) | |
| 164 | 추가: .args([ | |
| 165 | 추가: "--exact", | |
| 166 | 추가: "screen::auto_destination_is_private_under_desktop_umask", | |
| 167 | 추가: "--nocapture", | |
| 168 | 추가: ]) | |
| 169 | 추가: .env(CHILD, "1") | |
| 170 | 추가: .output() | |
| 171 | 추가: .unwrap(); | |
| 172 | 추가: assert!( | |
| 173 | 추가: output.status.success(), | |
| 174 | 추가: "umask 0002 추출 회귀 실패: {}{}", | |
| 175 | 추가: String::from_utf8_lossy(&output.stdout), | |
| 176 | 추가: String::from_utf8_lossy(&output.stderr) | |
| 177 | 추가: ); | |
| 178 | 추가: return; | |
| 179 | 추가: } | |
| 180 | 추가: | |
| 181 | 추가: let mask = Command::new("sh").args(["-c", "umask"]).output().unwrap(); | |
| 182 | 추가: assert_eq!(String::from_utf8(mask.stdout).unwrap().trim(), "0002"); | |
| 183 | 추가: let scratch = Scratch::new(); | |
| 184 | 추가: let archive = scratch.path("sample.zip"); | |
| 185 | 추가: fs::copy( | |
| 186 | 추가: Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 187 | 추가: .join("../../tests/rust-app-real-worker/fixtures/sample.zip"), | |
| 188 | 추가: &archive, | |
| 189 | 추가: ) | |
| 190 | 추가: .unwrap(); | |
| 191 | 추가: let output = scratch.path("sample"); | |
| 192 | 추가: assert!(!output.exists()); | |
| 193 | 추가: let (factory, observed) = observed_factory(); | |
| 194 | 추가: let mut screen = Screen::new(factory); | |
| 195 | 추가: screen.open(&archive); | |
| 196 | 추가: screen.click("풀기"); | |
| 197 | 추가: assert!(screen.app.model.busy()); | |
| 198 | 추가: screen.settle(); | |
| 199 | 추가: assert_eq!( | |
| 200 | 추가: fs::metadata(&output).unwrap().permissions().mode() & 0o777, | |
| 201 | 추가: 0o700 | |
| 202 | 추가: ); | |
| 203 | 추가: assert_eq!( | |
| 204 | 추가: fs::read(output.join("content.txt")).unwrap(), | |
| 205 | 추가: b"Zipelo real worker flow\n" | |
| 206 | 추가: ); | |
| 207 | 추가: assert_eq!( | |
| 208 | 추가: screen.app.model.terminal.as_ref().unwrap().publication, | |
| 209 | 추가: Publication::Complete | |
| 210 | 추가: ); | |
| 211 | 추가: assert!( | |
| 212 | 추가: screen | |
| 213 | 추가: .render(vec![]) | |
| 214 | 추가: .iter() | |
| 215 | 추가: .any(|(text, _)| text == "압축을 풀었습니다") | |
| 216 | 추가: ); | |
| 217 | 추가: assert_reaped(&observed); | |
| 218 | 추가: } |
| @@ -1062,6 +1062,90 @@ mod widgets { | ||
| 1062 | 1062 | assert!(!shown.iter().any(|(text, _)| text == UNCERTAIN)); |
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 추가: #[test] | |
| 1066 | 추가: fn completed_results_keep_folder_action_and_show_durability_only_in_details() { | |
| 1067 | 추가: for creating in [false, true] { | |
| 1068 | 추가: for durability in [ | |
| 1069 | 추가: Durability::Synced, | |
| 1070 | 추가: Durability::Unconfirmed, | |
| 1071 | 추가: Durability::Failed, | |
| 1072 | 추가: ] { | |
| 1073 | 추가: let scratch = Folder::new(); | |
| 1074 | 추가: let factory = FakeFactory::default(); | |
| 1075 | 추가: let mut app = loaded(&scratch, &factory); | |
| 1076 | 추가: factory.state.borrow_mut().manual = true; | |
| 1077 | 추가: let ctx = egui::Context::default(); | |
| 1078 | 추가: let name = if creating { | |
| 1079 | 추가: let source = scratch.0.join("source.txt"); | |
| 1080 | 추가: fs::write(&source, b"source").unwrap(); | |
| 1081 | 추가: app.add_sources(vec![source]); | |
| 1082 | 추가: policy_render(&ctx, &mut app, vec![]); | |
| 1083 | 추가: policy_click(&ctx, &mut app, "만들기"); | |
| 1084 | 추가: match factory.state.borrow().starts.last().unwrap() { | |
| 1085 | 추가: Start::CreateZip { output_file, .. } => output_file | |
| 1086 | 추가: .file_name() | |
| 1087 | 추가: .unwrap() | |
| 1088 | 추가: .to_str() | |
| 1089 | 추가: .unwrap() | |
| 1090 | 추가: .to_owned(), | |
| 1091 | 추가: _ => panic!("생성 요청 누락"), | |
| 1092 | 추가: } | |
| 1093 | 추가: } else { | |
| 1094 | 추가: assert!(app.begin_extract()); | |
| 1095 | 추가: "읽어주세요.txt".to_owned() | |
| 1096 | 추가: }; | |
| 1097 | 추가: { | |
| 1098 | 추가: let mut worker = factory.state.borrow_mut(); | |
| 1099 | 추가: worker.frame(Event::Accepted { encryption: false }); | |
| 1100 | 추가: worker.frame(Event::Output { | |
| 1101 | 추가: entry_id: None, | |
| 1102 | 추가: relative_name: name, | |
| 1103 | 추가: disposition: Disposition::Created, | |
| 1104 | 추가: }); | |
| 1105 | 추가: worker.finish(Outcome::Completed, Publication::Complete); | |
| 1106 | 추가: for event in &mut worker.queue { | |
| 1107 | 추가: if let HostEvent::Frame { | |
| 1108 | 추가: event: Event::Terminal(terminal), | |
| 1109 | 추가: .. | |
| 1110 | 추가: } = event | |
| 1111 | 추가: { | |
| 1112 | 추가: terminal.durability = durability; | |
| 1113 | 추가: } | |
| 1114 | 추가: } | |
| 1115 | 추가: } | |
| 1116 | 추가: for _ in 0..30 { | |
| 1117 | 추가: policy_render(&ctx, &mut app, vec![]); | |
| 1118 | 추가: } | |
| 1119 | 추가: let shown = policy_render(&ctx, &mut app, vec![]); | |
| 1120 | 추가: let title = if creating { | |
| 1121 | 추가: "ZIP 파일을 만들었습니다" | |
| 1122 | 추가: } else { | |
| 1123 | 추가: "압축을 풀었습니다" | |
| 1124 | 추가: }; | |
| 1125 | 추가: assert!( | |
| 1126 | 추가: shown.iter().any(|(text, _)| text == title), | |
| 1127 | 추가: "{durability:?}: {shown:?}" | |
| 1128 | 추가: ); | |
| 1129 | 추가: assert!(shown.iter().any(|(text, _)| text == "폴더 열기")); | |
| 1130 | 추가: assert!( | |
| 1131 | 추가: !shown | |
| 1132 | 추가: .iter() | |
| 1133 | 추가: .any(|(text, _)| text == "다시 시도" || text == SYNC_WARNING) | |
| 1134 | 추가: ); | |
| 1135 | 추가: policy_click(&ctx, &mut app, "자세히 보기"); | |
| 1136 | 추가: let details = policy_render(&ctx, &mut app, vec![]); | |
| 1137 | 추가: assert_eq!( | |
| 1138 | 추가: details.iter().any(|(text, _)| text == SYNC_WARNING), | |
| 1139 | 추가: durability != Durability::Synced | |
| 1140 | 추가: ); | |
| 1141 | 추가: policy_click(&ctx, &mut app, "자세히 닫기"); | |
| 1142 | 추가: let closed = policy_render(&ctx, &mut app, vec![]); | |
| 1143 | 추가: assert!(!closed.iter().any(|(text, _)| text == SYNC_WARNING)); | |
| 1144 | 추가: assert!(closed.iter().any(|(text, _)| text == "폴더 열기")); | |
| 1145 | 추가: } | |
| 1146 | 추가: } | |
| 1147 | 추가: } | |
| 1148 | 추가: | |
| 1065 | 1149 | fn picker_frame( |
| 1066 | 1150 | ctx: &egui::Context, |
| 1067 | 1151 | picker: &mut Picker, |