Merge pull request #144 from Team-LJY/fix/archive-open-and-context-extract
압축파일 안 파일 열기와 선택 항목 풀기 메뉴 추가
- 작성자
- LeeJunyoung
- 작성 시각
- 커밋
8bd3e627725ad29af8fc67289f6333f148192ce5
변경된 파일 23개
+2,356-29변경 내용이 커서 일부 파일의 Diff를 생략했어요. 생략한 파일은 파일 보기나 Raw로 확인할 수 있어요.
| @@ -200,6 +200,12 @@ dependencies = [ | ||
| 200 | 200 | "generic-array", |
| 201 | 201 | ] |
| 202 | 202 | |
| 203 | 추가: [[package]] | |
| 204 | 추가: name = "itoa" | |
| 205 | 추가: version = "1.0.19" | |
| 206 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 207 | 추가: checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" | |
| 208 | 추가: | |
| 203 | 209 | [[package]] |
| 204 | 210 | name = "libbz2-rs-sys" |
| 205 | 211 | version = "0.2.6" |
| @@ -221,6 +227,12 @@ dependencies = [ | ||
| 221 | 227 | "sha2 0.11.1", |
| 222 | 228 | ] |
| 223 | 229 | |
| 230 | 추가: [[package]] | |
| 231 | 추가: name = "memchr" | |
| 232 | 추가: version = "2.8.3" | |
| 233 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 234 | 추가: checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" | |
| 235 | 추가: | |
| 224 | 236 | [[package]] |
| 225 | 237 | name = "miniz_oxide" |
| 226 | 238 | version = "0.8.9" |
| @@ -264,6 +276,66 @@ dependencies = [ | ||
| 264 | 276 | "miniz_oxide 0.8.9", |
| 265 | 277 | ] |
| 266 | 278 | |
| 279 | 추가: [[package]] | |
| 280 | 추가: name = "proc-macro2" | |
| 281 | 추가: version = "1.0.107" | |
| 282 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 283 | 추가: checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" | |
| 284 | 추가: dependencies = [ | |
| 285 | 추가: "unicode-ident", | |
| 286 | 추가: ] | |
| 287 | 추가: | |
| 288 | 추가: [[package]] | |
| 289 | 추가: name = "quote" | |
| 290 | 추가: version = "1.0.47" | |
| 291 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 292 | 추가: checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" | |
| 293 | 추가: dependencies = [ | |
| 294 | 추가: "proc-macro2", | |
| 295 | 추가: ] | |
| 296 | 추가: | |
| 297 | 추가: [[package]] | |
| 298 | 추가: name = "serde" | |
| 299 | 추가: version = "1.0.229" | |
| 300 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 301 | 추가: checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" | |
| 302 | 추가: dependencies = [ | |
| 303 | 추가: "serde_core", | |
| 304 | 추가: ] | |
| 305 | 추가: | |
| 306 | 추가: [[package]] | |
| 307 | 추가: name = "serde_core" | |
| 308 | 추가: version = "1.0.229" | |
| 309 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 310 | 추가: checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" | |
| 311 | 추가: dependencies = [ | |
| 312 | 추가: "serde_derive", | |
| 313 | 추가: ] | |
| 314 | 추가: | |
| 315 | 추가: [[package]] | |
| 316 | 추가: name = "serde_derive" | |
| 317 | 추가: version = "1.0.229" | |
| 318 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 319 | 추가: checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" | |
| 320 | 추가: dependencies = [ | |
| 321 | 추가: "proc-macro2", | |
| 322 | 추가: "quote", | |
| 323 | 추가: "syn", | |
| 324 | 추가: ] | |
| 325 | 추가: | |
| 326 | 추가: [[package]] | |
| 327 | 추가: name = "serde_json" | |
| 328 | 추가: version = "1.0.154" | |
| 329 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 330 | 추가: checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" | |
| 331 | 추가: dependencies = [ | |
| 332 | 추가: "itoa", | |
| 333 | 추가: "memchr", | |
| 334 | 추가: "serde", | |
| 335 | 추가: "serde_core", | |
| 336 | 추가: "zmij", | |
| 337 | 추가: ] | |
| 338 | 추가: | |
| 267 | 339 | [[package]] |
| 268 | 340 | name = "sha1" |
| 269 | 341 | version = "0.10.7" |
| @@ -309,12 +381,29 @@ version = "2.6.1" | ||
| 309 | 381 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 310 | 382 | checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" |
| 311 | 383 | |
| 384 | 추가: [[package]] | |
| 385 | 추가: name = "syn" | |
| 386 | 추가: version = "3.0.10" | |
| 387 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 388 | 추가: checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" | |
| 389 | 추가: dependencies = [ | |
| 390 | 추가: "proc-macro2", | |
| 391 | 추가: "quote", | |
| 392 | 추가: "unicode-ident", | |
| 393 | 추가: ] | |
| 394 | 추가: | |
| 312 | 395 | [[package]] |
| 313 | 396 | name = "typenum" |
| 314 | 397 | version = "1.20.1" |
| 315 | 398 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 316 | 399 | checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" |
| 317 | 400 | |
| 401 | 추가: [[package]] | |
| 402 | 추가: name = "unicode-ident" | |
| 403 | 추가: version = "1.0.27" | |
| 404 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 405 | 추가: checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" | |
| 406 | 추가: | |
| 318 | 407 | [[package]] |
| 319 | 408 | name = "version_check" |
| 320 | 409 | version = "0.9.5" |
| @@ -337,6 +426,8 @@ dependencies = [ | ||
| 337 | 426 | "lzma-rust2", |
| 338 | 427 | "pbkdf2", |
| 339 | 428 | "png", |
| 429 | 추가: "serde", | |
| 430 | 추가: "serde_json", | |
| 340 | 431 | "sha1", |
| 341 | 432 | "sha2 0.10.9", |
| 342 | 433 | "subtle", |
| @@ -359,6 +450,12 @@ version = "0.6.8" | ||
| 359 | 450 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 360 | 451 | checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" |
| 361 | 452 | |
| 453 | 추가: [[package]] | |
| 454 | 추가: name = "zmij" | |
| 455 | 추가: version = "1.0.23" | |
| 456 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 457 | 추가: checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" | |
| 458 | 추가: | |
| 362 | 459 | [[package]] |
| 363 | 460 | name = "zune-core" |
| 364 | 461 | version = "0.5.3" |
| @@ -21,6 +21,10 @@ zeroize = "=1.9.1" | ||
| 21 | 21 | sha2 = "=0.10.9" |
| 22 | 22 | zlib-rs = { version = "=0.6.8", default-features = false, features = ["rust-allocator"] } |
| 23 | 23 | |
| 24 | 추가: [target.'cfg(target_os = "linux")'.dependencies] | |
| 25 | 추가: serde = "=1.0.229" | |
| 26 | 추가: serde_json = "=1.0.154" | |
| 27 | 추가: | |
| 24 | 28 | [workspace] |
| 25 | 29 | exclude = ["vendor/zune-jpeg"] |
| 26 | 30 |
| @@ -194,6 +194,210 @@ mod platform { | ||
| 194 | 194 | fn renameat(fd: i32, path: *const i8, newfd: i32, newpath: *const i8) -> i32; |
| 195 | 195 | fn unlinkat(fd: i32, path: *const i8, flags: i32) -> i32; |
| 196 | 196 | fn geteuid() -> u32; |
| 197 | 추가: fn getegid() -> u32; | |
| 198 | 추가: fn fgetxattr( | |
| 199 | 추가: fd: i32, | |
| 200 | 추가: name: *const std::ffi::c_char, | |
| 201 | 추가: value: *mut std::ffi::c_void, | |
| 202 | 추가: size: usize, | |
| 203 | 추가: ) -> isize; | |
| 204 | 추가: fn getgrgid_r( | |
| 205 | 추가: gid: u32, | |
| 206 | 추가: group: *mut Group, | |
| 207 | 추가: buffer: *mut i8, | |
| 208 | 추가: length: usize, | |
| 209 | 추가: result: *mut *mut Group, | |
| 210 | 추가: ) -> i32; | |
| 211 | 추가: } | |
| 212 | 추가: #[repr(C)] | |
| 213 | 추가: struct Group { | |
| 214 | 추가: name: *mut i8, | |
| 215 | 추가: password: *mut i8, | |
| 216 | 추가: gid: u32, | |
| 217 | 추가: members: *mut *mut i8, | |
| 218 | 추가: } | |
| 219 | 추가: // 없는 경로만 허용하며 중간 심볼릭 링크와 확인 오류는 거부함. | |
| 220 | 추가: fn path_is_absent(path: &Path) -> bool { | |
| 221 | 추가: let mut prefix = std::path::PathBuf::new(); | |
| 222 | 추가: for component in path.components() { | |
| 223 | 추가: prefix.push(component.as_os_str()); | |
| 224 | 추가: match std::fs::symlink_metadata(&prefix) { | |
| 225 | 추가: Ok(metadata) if metadata.is_dir() => {} | |
| 226 | 추가: Ok(_) => return false, | |
| 227 | 추가: Err(error) if error.kind() == std::io::ErrorKind::NotFound => return true, | |
| 228 | 추가: Err(_) => return false, | |
| 229 | 추가: } | |
| 230 | 추가: } | |
| 231 | 추가: false | |
| 232 | 추가: } | |
| 233 | 추가: | |
| 234 | 추가: fn sss_is_unused(socket: &Path, cache: &Path) -> bool { | |
| 235 | 추가: path_is_absent(socket) | |
| 236 | 추가: && ["passwd", "group", "initgr"] | |
| 237 | 추가: .iter() | |
| 238 | 추가: .all(|name| path_is_absent(&cache.join(name))) | |
| 239 | 추가: } | |
| 240 | 추가: | |
| 241 | 추가: // sss는 소켓과 캐시가 모두 없을 때만 빈 소스로 취급함. | |
| 242 | 추가: fn primary_group_is_private(gid: u32) -> bool { | |
| 243 | 추가: let Ok(policy) = std::fs::read_to_string("/etc/nsswitch.conf") else { | |
| 244 | 추가: return false; | |
| 245 | 추가: }; | |
| 246 | 추가: let mut databases = [None, None, None]; | |
| 247 | 추가: for line in policy.lines() { | |
| 248 | 추가: let line = line.split('#').next().unwrap_or_default(); | |
| 249 | 추가: let Some((database, sources)) = line.split_once(':') else { | |
| 250 | 추가: continue; | |
| 251 | 추가: }; | |
| 252 | 추가: let index = match database.trim() { | |
| 253 | 추가: "passwd" => 0, | |
| 254 | 추가: "group" => 1, | |
| 255 | 추가: "initgroups" => 2, | |
| 256 | 추가: _ => continue, | |
| 257 | 추가: }; | |
| 258 | 추가: if databases[index] | |
| 259 | 추가: .replace(sources.split_whitespace().collect::<Vec<_>>()) | |
| 260 | 추가: .is_some() | |
| 261 | 추가: { | |
| 262 | 추가: return false; | |
| 263 | 추가: } | |
| 264 | 추가: } | |
| 265 | 추가: let [Some(passwd), Some(group), initgroups] = databases else { | |
| 266 | 추가: return false; | |
| 267 | 추가: }; | |
| 268 | 추가: let mut has_systemd = false; | |
| 269 | 추가: let mut has_sss = false; | |
| 270 | 추가: // initgroups가 생략되어도 기본값인 group 소스를 검사함. | |
| 271 | 추가: for source in [Some(passwd), Some(group), initgroups] | |
| 272 | 추가: .into_iter() | |
| 273 | 추가: .flatten() | |
| 274 | 추가: { | |
| 275 | 추가: if !matches!( | |
| 276 | 추가: source.as_slice(), | |
| 277 | 추가: ["files"] | ["files", "systemd"] | ["files", "sss"] | ["files", "systemd", "sss"] | |
| 278 | 추가: ) { | |
| 279 | 추가: return false; | |
| 280 | 추가: } | |
| 281 | 추가: has_systemd |= source.contains(&"systemd"); | |
| 282 | 추가: has_sss |= source.contains(&"sss"); | |
| 283 | 추가: } | |
| 284 | 추가: if has_sss | |
| 285 | 추가: && !sss_is_unused( | |
| 286 | 추가: Path::new("/var/lib/sss/pipes/nss"), | |
| 287 | 추가: Path::new("/var/lib/sss/mc"), | |
| 288 | 추가: ) | |
| 289 | 추가: { | |
| 290 | 추가: return false; | |
| 291 | 추가: } | |
| 292 | 추가: let Ok(accounts) = std::fs::read_to_string("/etc/passwd") else { | |
| 293 | 추가: return false; | |
| 294 | 추가: }; | |
| 295 | 추가: let current_uid = unsafe { geteuid() }; | |
| 296 | 추가: let mut current_name = None; | |
| 297 | 추가: for account in accounts.lines() { | |
| 298 | 추가: if account.trim().is_empty() || account.starts_with('#') { | |
| 299 | 추가: continue; | |
| 300 | 추가: } | |
| 301 | 추가: let fields: Vec<_> = account.split(':').collect(); | |
| 302 | 추가: if fields.len() != 7 || fields[0].is_empty() { | |
| 303 | 추가: return false; | |
| 304 | 추가: } | |
| 305 | 추가: let (Ok(uid), Ok(primary_gid)) = (fields[2].parse::<u32>(), fields[3].parse::<u32>()) | |
| 306 | 추가: else { | |
| 307 | 추가: return false; | |
| 308 | 추가: }; | |
| 309 | 추가: if primary_gid == gid { | |
| 310 | 추가: if uid != current_uid { | |
| 311 | 추가: return false; | |
| 312 | 추가: } | |
| 313 | 추가: if current_name.replace(fields[0]).is_some() { | |
| 314 | 추가: return false; | |
| 315 | 추가: } | |
| 316 | 추가: } | |
| 317 | 추가: } | |
| 318 | 추가: let Some(current_name) = current_name else { | |
| 319 | 추가: return false; | |
| 320 | 추가: }; | |
| 321 | 추가: !has_systemd | |
| 322 | 추가: || crate::systemd_userdb::group_is_private( | |
| 323 | 추가: gid, | |
| 324 | 추가: current_uid, | |
| 325 | 추가: current_name, | |
| 326 | 추가: Path::new("/run/systemd/userdb/"), | |
| 327 | 추가: &[ | |
| 328 | 추가: Path::new("/etc/userdb"), | |
| 329 | 추가: Path::new("/run/userdb"), | |
| 330 | 추가: Path::new("/run/host/userdb"), | |
| 331 | 추가: Path::new("/usr/local/lib/userdb"), | |
| 332 | 추가: Path::new("/usr/lib/userdb"), | |
| 333 | 추가: ], | |
| 334 | 추가: ) | |
| 335 | 추가: } | |
| 336 | 추가: | |
| 337 | 추가: // 기본 구성원과 보조 구성원을 모두 확인함. | |
| 338 | 추가: fn private_group(gid: u32) -> bool { | |
| 339 | 추가: if gid != unsafe { getegid() } || !primary_group_is_private(gid) { | |
| 340 | 추가: return false; | |
| 341 | 추가: } | |
| 342 | 추가: let mut group = Group { | |
| 343 | 추가: name: std::ptr::null_mut(), | |
| 344 | 추가: password: std::ptr::null_mut(), | |
| 345 | 추가: gid: 0, | |
| 346 | 추가: members: std::ptr::null_mut(), | |
| 347 | 추가: }; | |
| 348 | 추가: let mut result = std::ptr::null_mut(); | |
| 349 | 추가: let mut buffer = vec![0i8; 16 * 1024]; | |
| 350 | 추가: let status = unsafe { | |
| 351 | 추가: getgrgid_r( | |
| 352 | 추가: gid, | |
| 353 | 추가: &mut group, | |
| 354 | 추가: buffer.as_mut_ptr(), | |
| 355 | 추가: buffer.len(), | |
| 356 | 추가: &mut result, | |
| 357 | 추가: ) | |
| 358 | 추가: }; | |
| 359 | 추가: // 그룹 정보를 읽지 못하면 안전하다고 볼 근거가 없으므로 거부함. | |
| 360 | 추가: status == 0 | |
| 361 | 추가: && !result.is_null() | |
| 362 | 추가: && group.gid == gid | |
| 363 | 추가: && !group.members.is_null() | |
| 364 | 추가: && unsafe { *group.members }.is_null() | |
| 365 | 추가: } | |
| 366 | 추가: fn access_acl_has_no_named_entries(file: &File) -> bool { | |
| 367 | 추가: // 이름 없는 ACL은 소유자, 그룹, other와 선택적 mask의 최대 4항목임. | |
| 368 | 추가: let mut bytes = [0u8; 4 + 4 * 8]; | |
| 369 | 추가: // 경로를 다시 해석하지 않고 판정 대상 폴더의 접근 ACL을 읽음. | |
| 370 | 추가: let length = unsafe { | |
| 371 | 추가: fgetxattr( | |
| 372 | 추가: file.as_raw_fd(), | |
| 373 | 추가: c"system.posix_acl_access".as_ptr(), | |
| 374 | 추가: bytes.as_mut_ptr().cast(), | |
| 375 | 추가: bytes.len(), | |
| 376 | 추가: ) | |
| 377 | 추가: }; | |
| 378 | 추가: if length < 0 { | |
| 379 | 추가: // 속성 없음과 미지원 외에는 ERANGE를 포함해 거부함. | |
| 380 | 추가: return matches!( | |
| 381 | 추가: std::io::Error::last_os_error().raw_os_error(), | |
| 382 | 추가: Some(61 | 95) | |
| 383 | 추가: ); | |
| 384 | 추가: } | |
| 385 | 추가: let tags: &[u16] = match length { | |
| 386 | 추가: 28 => &[1, 4, 32], | |
| 387 | 추가: 36 => &[1, 4, 16, 32], | |
| 388 | 추가: _ => return false, | |
| 389 | 추가: }; | |
| 390 | 추가: if u32::from_le_bytes(bytes[..4].try_into().unwrap()) != 2 { | |
| 391 | 추가: return false; | |
| 392 | 추가: } | |
| 393 | 추가: bytes[4..length as usize] | |
| 394 | 추가: .chunks_exact(8) | |
| 395 | 추가: .zip(tags) | |
| 396 | 추가: .all(|(entry, expected)| { | |
| 397 | 추가: u16::from_le_bytes(entry[..2].try_into().unwrap()) == *expected | |
| 398 | 추가: && u16::from_le_bytes(entry[2..4].try_into().unwrap()) & !7 == 0 | |
| 399 | 추가: && u32::from_le_bytes(entry[4..8].try_into().unwrap()) == u32::MAX | |
| 400 | 추가: }) | |
| 197 | 401 | } |
| 198 | 402 | pub struct Dir { |
| 199 | 403 | file: File, |
| @@ -242,7 +446,14 @@ mod platform { | ||
| 242 | 446 | fn trusted(&self) -> Result<()> { |
| 243 | 447 | let m = self.file.metadata().map_err(|_| ErrorCode::Io)?; |
| 244 | 448 | // 다른 계정이 바꿀 수 있는 출력 폴더를 거부함. |
| 245 | 삭제: if !m.is_dir() || m.uid() != unsafe { geteuid() } || m.mode() & 0o022 != 0 { | |
| 449 | 추가: // 그룹 쓰기는 이름 있는 접근 ACL이 없고 개인 그룹일 때만 허용함. | |
| 450 | 추가: let group_writable = m.mode() & 0o020 != 0; | |
| 451 | 추가: if !m.is_dir() | |
| 452 | 추가: || m.uid() != unsafe { geteuid() } | |
| 453 | 추가: || m.mode() & 0o002 != 0 | |
| 454 | 추가: || (group_writable | |
| 455 | 추가: && (!access_acl_has_no_named_entries(&self.file) || !private_group(m.gid()))) | |
| 456 | 추가: { | |
| 246 | 457 | return Err(ErrorCode::UnsafePath); |
| 247 | 458 | } |
| 248 | 459 | Ok(()) |
| @@ -16,6 +16,10 @@ mod space; | ||
| 16 | 16 | mod split_seven_zip; |
| 17 | 17 | mod spool; |
| 18 | 18 | mod streaming; |
| 19 | 추가: pub mod tree_remove; | |
| 19 | 20 | pub mod wire; |
| 20 | 21 | mod zip_extra; |
| 21 | 22 | mod zip_recovery; |
| 23 | 추가: | |
| 24 | 추가: #[cfg(target_os = "linux")] | |
| 25 | 추가: mod systemd_userdb; |
| @@ -0,0 +1,363 @@ | ||
| 1 | 추가: use serde::de::{self, Deserialize, Deserializer, MapAccess, SeqAccess, Visitor}; | |
| 2 | 추가: use serde_json::{Map, Value}; | |
| 3 | 추가: use std::collections::BTreeMap; | |
| 4 | 추가: use std::fs; | |
| 5 | 추가: use std::io::{BufRead, BufReader, Write}; | |
| 6 | 추가: use std::os::unix::{ffi::OsStrExt, fs::FileTypeExt, io::FromRawFd, net::UnixStream}; | |
| 7 | 추가: use std::path::Path; | |
| 8 | 추가: use std::time::{Duration, Instant}; | |
| 9 | 추가: | |
| 10 | 추가: // 중복 키는 해석 순서에 따라 판정이 달라질 수 있어 모든 깊이에서 거부함. | |
| 11 | 추가: struct Strict(Value); | |
| 12 | 추가: impl<'de> Deserialize<'de> for Strict { | |
| 13 | 추가: fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { | |
| 14 | 추가: struct Json; | |
| 15 | 추가: impl<'de> Visitor<'de> for Json { | |
| 16 | 추가: type Value = Strict; | |
| 17 | 추가: fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | |
| 18 | 추가: f.write_str("unambiguous JSON") | |
| 19 | 추가: } | |
| 20 | 추가: fn visit_bool<E: de::Error>(self, v: bool) -> Result<Strict, E> { | |
| 21 | 추가: Ok(Strict(Value::Bool(v))) | |
| 22 | 추가: } | |
| 23 | 추가: fn visit_i64<E: de::Error>(self, v: i64) -> Result<Strict, E> { | |
| 24 | 추가: Ok(Strict(v.into())) | |
| 25 | 추가: } | |
| 26 | 추가: fn visit_u64<E: de::Error>(self, v: u64) -> Result<Strict, E> { | |
| 27 | 추가: Ok(Strict(v.into())) | |
| 28 | 추가: } | |
| 29 | 추가: fn visit_f64<E: de::Error>(self, v: f64) -> Result<Strict, E> { | |
| 30 | 추가: serde_json::Number::from_f64(v) | |
| 31 | 추가: .map(|v| Strict(Value::Number(v))) | |
| 32 | 추가: .ok_or_else(|| E::custom("invalid number")) | |
| 33 | 추가: } | |
| 34 | 추가: fn visit_str<E: de::Error>(self, v: &str) -> Result<Strict, E> { | |
| 35 | 추가: Ok(Strict(Value::String(v.into()))) | |
| 36 | 추가: } | |
| 37 | 추가: fn visit_unit<E: de::Error>(self) -> Result<Strict, E> { | |
| 38 | 추가: Ok(Strict(Value::Null)) | |
| 39 | 추가: } | |
| 40 | 추가: fn visit_seq<A: SeqAccess<'de>>(self, mut seq: A) -> Result<Strict, A::Error> { | |
| 41 | 추가: let mut values = Vec::new(); | |
| 42 | 추가: while let Some(Strict(v)) = seq.next_element()? { | |
| 43 | 추가: values.push(v); | |
| 44 | 추가: } | |
| 45 | 추가: Ok(Strict(Value::Array(values))) | |
| 46 | 추가: } | |
| 47 | 추가: fn visit_map<A: MapAccess<'de>>(self, mut map: A) -> Result<Strict, A::Error> { | |
| 48 | 추가: let mut values = Map::new(); | |
| 49 | 추가: while let Some((key, Strict(v))) = map.next_entry::<String, Strict>()? { | |
| 50 | 추가: if values.insert(key, v).is_some() { | |
| 51 | 추가: return Err(de::Error::custom("duplicate key")); | |
| 52 | 추가: } | |
| 53 | 추가: } | |
| 54 | 추가: Ok(Strict(Value::Object(values))) | |
| 55 | 추가: } | |
| 56 | 추가: } | |
| 57 | 추가: deserializer.deserialize_any(Json) | |
| 58 | 추가: } | |
| 59 | 추가: } | |
| 60 | 추가: | |
| 61 | 추가: type Check<T> = Result<T, ()>; | |
| 62 | 추가: const MAX_FRAME: usize = 1024 * 1024; | |
| 63 | 추가: const MAX_TOTAL: usize = 16 * MAX_FRAME; | |
| 64 | 추가: const MAX_RECORDS: usize = 65_536; | |
| 65 | 추가: | |
| 66 | 추가: fn directory(path: &Path) -> Check<bool> { | |
| 67 | 추가: let mut prefix = std::path::PathBuf::new(); | |
| 68 | 추가: for part in path.components() { | |
| 69 | 추가: prefix.push(part.as_os_str()); | |
| 70 | 추가: match fs::symlink_metadata(&prefix) { | |
| 71 | 추가: Ok(m) if m.is_dir() => {} | |
| 72 | 추가: Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(false), | |
| 73 | 추가: _ => return Err(()), | |
| 74 | 추가: } | |
| 75 | 추가: } | |
| 76 | 추가: Ok(true) | |
| 77 | 추가: } | |
| 78 | 추가: | |
| 79 | 추가: fn name(value: &Value) -> Check<&str> { | |
| 80 | 추가: value | |
| 81 | 추가: .as_str() | |
| 82 | 추가: .filter(|s| !s.is_empty() && !s.chars().any(char::is_control)) | |
| 83 | 추가: .ok_or(()) | |
| 84 | 추가: } | |
| 85 | 추가: fn id(value: &Value) -> Check<u32> { | |
| 86 | 추가: value | |
| 87 | 추가: .as_u64() | |
| 88 | 추가: .and_then(|v| u32::try_from(v).ok()) | |
| 89 | 추가: .filter(|v| *v != u32::MAX) | |
| 90 | 추가: .ok_or(()) | |
| 91 | 추가: } | |
| 92 | 추가: fn strings(value: Option<&Value>) -> Check<Vec<&str>> { | |
| 93 | 추가: match value { | |
| 94 | 추가: None => Ok(Vec::new()), | |
| 95 | 추가: Some(Value::Array(values)) => values.iter().map(name).collect(), | |
| 96 | 추가: _ => Err(()), | |
| 97 | 추가: } | |
| 98 | 추가: } | |
| 99 | 추가: fn record(parameters: &Value) -> Check<&Value> { | |
| 100 | 추가: match parameters.get("incomplete") { | |
| 101 | 추가: None | Some(Value::Bool(false)) => {} | |
| 102 | 추가: _ => return Err(()), | |
| 103 | 추가: } | |
| 104 | 추가: let record = parameters | |
| 105 | 추가: .get("record") | |
| 106 | 추가: .filter(|v| v.is_object()) | |
| 107 | 추가: .ok_or(())?; | |
| 108 | 추가: // 기기별 덮어쓰기를 해석하지 않은 상태에서는 거부함. | |
| 109 | 추가: for key in ["binding", "perMachine"] { | |
| 110 | 추가: match record.get(key) { | |
| 111 | 추가: None => {} | |
| 112 | 추가: Some(Value::Object(v)) if key == "binding" && v.is_empty() => {} | |
| 113 | 추가: Some(Value::Array(v)) if key == "perMachine" && v.is_empty() => {} | |
| 114 | 추가: _ => return Err(()), | |
| 115 | 추가: } | |
| 116 | 추가: } | |
| 117 | 추가: Ok(record) | |
| 118 | 추가: } | |
| 119 | 추가: | |
| 120 | 추가: struct Budget { | |
| 121 | 추가: deadline: Instant, | |
| 122 | 추가: bytes: usize, | |
| 123 | 추가: records: usize, | |
| 124 | 추가: } | |
| 125 | 추가: impl Budget { | |
| 126 | 추가: fn remaining(&self) -> Check<Duration> { | |
| 127 | 추가: self.deadline | |
| 128 | 추가: .checked_duration_since(Instant::now()) | |
| 129 | 추가: .filter(|d| !d.is_zero()) | |
| 130 | 추가: .ok_or(()) | |
| 131 | 추가: } | |
| 132 | 추가: } | |
| 133 | 추가: | |
| 134 | 추가: // Unix 소켓의 대기열이 가득 차도 연결 단계에서 무한히 기다리지 않음. | |
| 135 | 추가: fn connect(path: &Path) -> Check<UnixStream> { | |
| 136 | 추가: #[repr(C)] | |
| 137 | 추가: struct Address { | |
| 138 | 추가: family: u16, | |
| 139 | 추가: path: [u8; 108], | |
| 140 | 추가: } | |
| 141 | 추가: unsafe extern "C" { | |
| 142 | 추가: fn socket(domain: i32, kind: i32, protocol: i32) -> i32; | |
| 143 | 추가: fn connect(fd: i32, address: *const Address, size: u32) -> i32; | |
| 144 | 추가: } | |
| 145 | 추가: let bytes = path.as_os_str().as_bytes(); | |
| 146 | 추가: if bytes.contains(&0) || bytes.len() >= 108 { | |
| 147 | 추가: return Err(()); | |
| 148 | 추가: } | |
| 149 | 추가: let mut address = Address { | |
| 150 | 추가: family: 1, | |
| 151 | 추가: path: [0; 108], | |
| 152 | 추가: }; | |
| 153 | 추가: address.path[..bytes.len()].copy_from_slice(bytes); | |
| 154 | 추가: let fd = unsafe { socket(1, 1 | 0x80000 | 0x800, 0) }; | |
| 155 | 추가: if fd < 0 { | |
| 156 | 추가: return Err(()); | |
| 157 | 추가: } | |
| 158 | 추가: let stream = unsafe { UnixStream::from_raw_fd(fd) }; | |
| 159 | 추가: if unsafe { connect(fd, &address, (2 + bytes.len() + 1) as u32) } != 0 { | |
| 160 | 추가: return Err(()); | |
| 161 | 추가: } | |
| 162 | 추가: stream.set_nonblocking(false).map_err(|_| ())?; | |
| 163 | 추가: Ok(stream) | |
| 164 | 추가: } | |
| 165 | 추가: | |
| 166 | 추가: fn query( | |
| 167 | 추가: path: &Path, | |
| 168 | 추가: service: &str, | |
| 169 | 추가: method: &str, | |
| 170 | 추가: budget: &mut Budget, | |
| 171 | 추가: mut check: impl FnMut(&Value) -> Check<()>, | |
| 172 | 추가: ) -> Check<()> { | |
| 173 | 추가: let mut stream = connect(path)?; | |
| 174 | 추가: stream | |
| 175 | 추가: .set_write_timeout(Some(budget.remaining()?)) | |
| 176 | 추가: .map_err(|_| ())?; | |
| 177 | 추가: let request = serde_json::json!({ | |
| 178 | 추가: "method": format!("io.systemd.UserDatabase.{method}"), | |
| 179 | 추가: "parameters": {"service": service}, "more": true, | |
| 180 | 추가: }); | |
| 181 | 추가: stream | |
| 182 | 추가: .write_all(request.to_string().as_bytes()) | |
| 183 | 추가: .map_err(|_| ())?; | |
| 184 | 추가: stream.write_all(&[0]).map_err(|_| ())?; | |
| 185 | 추가: let mut reader = BufReader::new(stream); | |
| 186 | 추가: loop { | |
| 187 | 추가: let mut frame = Vec::new(); | |
| 188 | 추가: loop { | |
| 189 | 추가: reader | |
| 190 | 추가: .get_ref() | |
| 191 | 추가: .set_read_timeout(Some(budget.remaining()?)) | |
| 192 | 추가: .map_err(|_| ())?; | |
| 193 | 추가: let chunk = reader.fill_buf().map_err(|_| ())?; | |
| 194 | 추가: if chunk.is_empty() { | |
| 195 | 추가: return Err(()); | |
| 196 | 추가: } | |
| 197 | 추가: let end = chunk.iter().position(|b| *b == 0); | |
| 198 | 추가: let n = end.map_or(chunk.len(), |i| i + 1); | |
| 199 | 추가: budget.bytes = budget | |
| 200 | 추가: .bytes | |
| 201 | 추가: .checked_add(n) | |
| 202 | 추가: .filter(|n| *n <= MAX_TOTAL) | |
| 203 | 추가: .ok_or(())?; | |
| 204 | 추가: if frame.len() + n > MAX_FRAME { | |
| 205 | 추가: return Err(()); | |
| 206 | 추가: } | |
| 207 | 추가: frame.extend_from_slice(&chunk[..n]); | |
| 208 | 추가: reader.consume(n); | |
| 209 | 추가: if end.is_some() { | |
| 210 | 추가: frame.pop(); | |
| 211 | 추가: break; | |
| 212 | 추가: } | |
| 213 | 추가: } | |
| 214 | 추가: budget.records += 1; | |
| 215 | 추가: if budget.records > MAX_RECORDS { | |
| 216 | 추가: return Err(()); | |
| 217 | 추가: } | |
| 218 | 추가: let Strict(reply) = serde_json::from_slice::<Strict>(&frame).map_err(|_| ())?; | |
| 219 | 추가: let object = reply.as_object().ok_or(())?; | |
| 220 | 추가: if object | |
| 221 | 추가: .keys() | |
| 222 | 추가: .any(|key| !matches!(key.as_str(), "parameters" | "error" | "continues")) | |
| 223 | 추가: { | |
| 224 | 추가: return Err(()); | |
| 225 | 추가: } | |
| 226 | 추가: let continues = match reply.get("continues") { | |
| 227 | 추가: None | Some(Value::Bool(false)) => false, | |
| 228 | 추가: Some(Value::Bool(true)) => true, | |
| 229 | 추가: _ => return Err(()), | |
| 230 | 추가: }; | |
| 231 | 추가: if let Some(error) = reply.get("error") { | |
| 232 | 추가: return if error.as_str() == Some("io.systemd.UserDatabase.NoRecordFound") | |
| 233 | 추가: && !continues | |
| 234 | 추가: && reply | |
| 235 | 추가: .get("parameters") | |
| 236 | 추가: .is_none_or(|v| v.as_object().is_some_and(|v| v.is_empty())) | |
| 237 | 추가: { | |
| 238 | 추가: Ok(()) | |
| 239 | 추가: } else { | |
| 240 | 추가: Err(()) | |
| 241 | 추가: }; | |
| 242 | 추가: } | |
| 243 | 추가: let parameters = reply | |
| 244 | 추가: .get("parameters") | |
| 245 | 추가: .filter(|v| v.is_object()) | |
| 246 | 추가: .ok_or(())?; | |
| 247 | 추가: check(parameters)?; | |
| 248 | 추가: if !continues { | |
| 249 | 추가: return Ok(()); | |
| 250 | 추가: } | |
| 251 | 추가: } | |
| 252 | 추가: } | |
| 253 | 추가: | |
| 254 | 추가: fn inspect(gid: u32, uid: u32, owner: &str, sockets: &Path, dropins: &[&Path]) -> Check<()> { | |
| 255 | 추가: for path in dropins { | |
| 256 | 추가: if directory(path)? && fs::read_dir(path).map_err(|_| ())?.next().is_some() { | |
| 257 | 추가: return Err(()); | |
| 258 | 추가: } | |
| 259 | 추가: } | |
| 260 | 추가: let mut groups = BTreeMap::<String, u32>::new(); | |
| 261 | 추가: let local = fs::read_to_string("/etc/group").map_err(|_| ())?; | |
| 262 | 추가: for line in local | |
| 263 | 추가: .lines() | |
| 264 | 추가: .filter(|v| !v.is_empty() && !v.starts_with('#')) | |
| 265 | 추가: { | |
| 266 | 추가: let fields: Vec<_> = line.split(':').collect(); | |
| 267 | 추가: if fields.len() != 4 || fields[0].is_empty() { | |
| 268 | 추가: return Err(()); | |
| 269 | 추가: } | |
| 270 | 추가: let group_gid = fields[2].parse::<u32>().map_err(|_| ())?; | |
| 271 | 추가: if group_gid == gid && fields[3].split(',').any(|v| !v.is_empty() && v != owner) { | |
| 272 | 추가: return Err(()); | |
| 273 | 추가: } | |
| 274 | 추가: if groups.insert(fields[0].into(), group_gid).is_some() { | |
| 275 | 추가: return Err(()); | |
| 276 | 추가: } | |
| 277 | 추가: } | |
| 278 | 추가: let mut services = Vec::new(); | |
| 279 | 추가: if directory(sockets)? { | |
| 280 | 추가: for entry in fs::read_dir(sockets).map_err(|_| ())? { | |
| 281 | 추가: let entry = entry.map_err(|_| ())?; | |
| 282 | 추가: let service = entry.file_name().into_string().map_err(|_| ())?; | |
| 283 | 추가: // 중계 서비스도 소켓 형식인지는 확인함. | |
| 284 | 추가: if !entry.file_type().map_err(|_| ())?.is_socket() { | |
| 285 | 추가: return Err(()); | |
| 286 | 추가: } | |
| 287 | 추가: if matches!( | |
| 288 | 추가: service.as_str(), | |
| 289 | 추가: "io.systemd.Multiplexer" | "io.systemd.NameServiceSwitch" | |
| 290 | 추가: ) { | |
| 291 | 추가: continue; | |
| 292 | 추가: } | |
| 293 | 추가: services.push((service, entry.path())); | |
| 294 | 추가: if services.len() > 256 { | |
| 295 | 추가: return Err(()); | |
| 296 | 추가: } | |
| 297 | 추가: } | |
| 298 | 추가: } | |
| 299 | 추가: let mut budget = Budget { | |
| 300 | 추가: deadline: Instant::now() + Duration::from_secs(5), | |
| 301 | 추가: bytes: 0, | |
| 302 | 추가: records: 0, | |
| 303 | 추가: }; | |
| 304 | 추가: // 모든 서비스의 그룹 이름을 먼저 모아 서비스 간 구성원도 검사함. | |
| 305 | 추가: for (service, path) in &services { | |
| 306 | 추가: query(path, service, "GetGroupRecord", &mut budget, |p| { | |
| 307 | 추가: let r = record(p)?; | |
| 308 | 추가: let group_name = name(&r["groupName"])?; | |
| 309 | 추가: let group_gid = id(&r["gid"])?; | |
| 310 | 추가: let members = strings(r.get("members"))?; | |
| 311 | 추가: if group_gid == gid && members.iter().any(|v| *v != owner) { | |
| 312 | 추가: return Err(()); | |
| 313 | 추가: } | |
| 314 | 추가: if groups | |
| 315 | 추가: .insert(group_name.into(), group_gid) | |
| 316 | 추가: .is_some_and(|v| v != group_gid) | |
| 317 | 추가: { | |
| 318 | 추가: return Err(()); | |
| 319 | 추가: } | |
| 320 | 추가: Ok(()) | |
| 321 | 추가: })?; | |
| 322 | 추가: } | |
| 323 | 추가: for (service, path) in &services { | |
| 324 | 추가: query(path, service, "GetUserRecord", &mut budget, |p| { | |
| 325 | 추가: let r = record(p)?; | |
| 326 | 추가: let user = name(&r["userName"])?; | |
| 327 | 추가: let user_uid = id(&r["uid"])?; | |
| 328 | 추가: let primary = id(&r["gid"])?; | |
| 329 | 추가: let is_owner = user_uid == uid && user == owner; | |
| 330 | 추가: if primary == gid && !is_owner { | |
| 331 | 추가: return Err(()); | |
| 332 | 추가: } | |
| 333 | 추가: for group in strings(r.get("memberOf"))? { | |
| 334 | 추가: let target = groups.get(group).ok_or(())?; | |
| 335 | 추가: if *target == gid && !is_owner { | |
| 336 | 추가: return Err(()); | |
| 337 | 추가: } | |
| 338 | 추가: } | |
| 339 | 추가: Ok(()) | |
| 340 | 추가: })?; | |
| 341 | 추가: query(path, service, "GetMemberships", &mut budget, |p| { | |
| 342 | 추가: let user = name(&p["userName"])?; | |
| 343 | 추가: let group = name(&p["groupName"])?; | |
| 344 | 추가: let target = groups.get(group).ok_or(())?; | |
| 345 | 추가: if *target == gid && user != owner { | |
| 346 | 추가: Err(()) | |
| 347 | 추가: } else { | |
| 348 | 추가: Ok(()) | |
| 349 | 추가: } | |
| 350 | 추가: })?; | |
| 351 | 추가: } | |
| 352 | 추가: Ok(()) | |
| 353 | 추가: } | |
| 354 | 추가: | |
| 355 | 추가: pub(crate) fn group_is_private( | |
| 356 | 추가: gid: u32, | |
| 357 | 추가: uid: u32, | |
| 358 | 추가: owner: &str, | |
| 359 | 추가: sockets: &Path, | |
| 360 | 추가: dropins: &[&Path], | |
| 361 | 추가: ) -> bool { | |
| 362 | 추가: inspect(gid, uid, owner, sockets, dropins).is_ok() | |
| 363 | 추가: } |
| @@ -0,0 +1,194 @@ | ||
| 1 | 추가: //! 열어 둔 폴더 핸들에 묶어서 폴더 안의 내용을 지움. | |
| 2 | 추가: //! 경로를 다시 해석하지 않으므로 확인한 뒤 경로가 바뀌어도 다른 폴더를 지우지 않음. | |
| 3 | 추가: | |
| 4 | 추가: use std::fs::File; | |
| 5 | 추가: use std::io; | |
| 6 | 추가: use std::path::Path; | |
| 7 | 추가: | |
| 8 | 추가: /// `dir` 핸들이 가리키는 폴더 안의 모든 항목을 지움. 폴더 자체는 지우지 않음. | |
| 9 | 추가: /// Linux는 핸들 기준 `unlinkat`으로 지우며 `path`는 쓰지 않음. | |
| 10 | 추가: /// Windows는 호출한 쪽이 공유 삭제를 허용하지 않고 `dir`을 열어 두어 폴더 이름이 | |
| 11 | 추가: /// 바뀌지 않게 한 상태에서만 `path`를 씀. | |
| 12 | 추가: pub fn remove_contents(dir: &File, path: &Path) -> io::Result<()> { | |
| 13 | 추가: platform::remove_contents(dir, path) | |
| 14 | 추가: } | |
| 15 | 추가: | |
| 16 | 추가: /// `dir` 핸들이 가리키는 폴더가 비어 있는지 확인함. 새로 만든 폴더를 핸들로 잡은 직후 쓰임. | |
| 17 | 추가: pub fn is_empty(dir: &File, path: &Path) -> io::Result<bool> { | |
| 18 | 추가: platform::is_empty(dir, path) | |
| 19 | 추가: } | |
| 20 | 추가: | |
| 21 | 추가: #[cfg(target_os = "linux")] | |
| 22 | 추가: mod platform { | |
| 23 | 추가: use std::ffi::{CStr, CString}; | |
| 24 | 추가: use std::fs::File; | |
| 25 | 추가: use std::io; | |
| 26 | 추가: use std::os::unix::{ | |
| 27 | 추가: fs::MetadataExt, | |
| 28 | 추가: io::{AsRawFd, FromRawFd}, | |
| 29 | 추가: }; | |
| 30 | 추가: use std::path::Path; | |
| 31 | 추가: | |
| 32 | 추가: #[cfg(any(target_arch = "aarch64", target_arch = "arm"))] | |
| 33 | 추가: const NOFOLLOW_DIRECTORY: i32 = 0x8000 | 0x4000; | |
| 34 | 추가: #[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))] | |
| 35 | 추가: const NOFOLLOW_DIRECTORY: i32 = 0x20000 | 0x10000; | |
| 36 | 추가: const CLOEXEC: i32 = 0x80000; | |
| 37 | 추가: const AT_REMOVEDIR: i32 = 0x200; | |
| 38 | 추가: const ENOENT: i32 = 2; | |
| 39 | 추가: const EPERM: i32 = 1; | |
| 40 | 추가: const EISDIR: i32 = 21; | |
| 41 | 추가: /// 깊게 중첩된 폴더에서 파일 디스크립터가 바닥나지 않게 하는 한도. | |
| 42 | 추가: const MAX_DEPTH: usize = 256; | |
| 43 | 추가: | |
| 44 | 추가: #[repr(C)] | |
| 45 | 추가: struct Dirent64 { | |
| 46 | 추가: inode: u64, | |
| 47 | 추가: offset: i64, | |
| 48 | 추가: length: u16, | |
| 49 | 추가: kind: u8, | |
| 50 | 추가: name: [i8; 256], | |
| 51 | 추가: } | |
| 52 | 추가: | |
| 53 | 추가: unsafe extern "C" { | |
| 54 | 추가: fn openat(fd: i32, path: *const i8, flags: i32, ...) -> i32; | |
| 55 | 추가: fn unlinkat(fd: i32, path: *const i8, flags: i32) -> i32; | |
| 56 | 추가: fn fdopendir(fd: i32) -> *mut std::ffi::c_void; | |
| 57 | 추가: fn readdir64(stream: *mut std::ffi::c_void) -> *mut Dirent64; | |
| 58 | 추가: fn rewinddir(stream: *mut std::ffi::c_void); | |
| 59 | 추가: fn closedir(stream: *mut std::ffi::c_void) -> i32; | |
| 60 | 추가: } | |
| 61 | 추가: | |
| 62 | 추가: pub fn remove_contents(dir: &File, _path: &Path) -> io::Result<()> { | |
| 63 | 추가: let device = dir.metadata()?.dev(); | |
| 64 | 추가: remove_children(dir, device, 0) | |
| 65 | 추가: } | |
| 66 | 추가: | |
| 67 | 추가: pub fn is_empty(dir: &File, _path: &Path) -> io::Result<bool> { | |
| 68 | 추가: Ok(names(dir)?.is_empty()) | |
| 69 | 추가: } | |
| 70 | 추가: | |
| 71 | 추가: fn names(dir: &File) -> io::Result<Vec<CString>> { | |
| 72 | 추가: let copy = dir.try_clone()?; | |
| 73 | 추가: let fd = std::os::unix::io::IntoRawFd::into_raw_fd(copy); | |
| 74 | 추가: // 복제한 디스크립터의 소유권은 폴더 스트림이 가져가며 closedir이 닫음. | |
| 75 | 추가: let stream = unsafe { fdopendir(fd) }; | |
| 76 | 추가: if stream.is_null() { | |
| 77 | 추가: let error = io::Error::last_os_error(); | |
| 78 | 추가: // 스트림을 만들지 못했으므로 복제한 디스크립터를 직접 돌려받아 닫음. | |
| 79 | 추가: drop(unsafe { File::from_raw_fd(fd) }); | |
| 80 | 추가: return Err(error); | |
| 81 | 추가: } | |
| 82 | 추가: // 복제한 디스크립터는 원본과 읽기 위치를 공유하므로 처음부터 읽음. | |
| 83 | 추가: unsafe { rewinddir(stream) }; | |
| 84 | 추가: let mut found = Vec::new(); | |
| 85 | 추가: loop { | |
| 86 | 추가: let entry = unsafe { readdir64(stream) }; | |
| 87 | 추가: if entry.is_null() { | |
| 88 | 추가: break; | |
| 89 | 추가: } | |
| 90 | 추가: // 반환된 항목은 다음 readdir64 호출 전까지 유효하며 바로 복사함. | |
| 91 | 추가: let name = unsafe { CStr::from_ptr((*entry).name.as_ptr()) }; | |
| 92 | 추가: let bytes = name.to_bytes(); | |
| 93 | 추가: if bytes != b"." && bytes != b".." { | |
| 94 | 추가: found.push(name.to_owned()); | |
| 95 | 추가: } | |
| 96 | 추가: } | |
| 97 | 추가: unsafe { closedir(stream) }; | |
| 98 | 추가: Ok(found) | |
| 99 | 추가: } | |
| 100 | 추가: | |
| 101 | 추가: fn unlink(dir: &File, name: &CString, flags: i32) -> io::Result<()> { | |
| 102 | 추가: // 부모 핸들 기준으로 이름 하나만 지움. | |
| 103 | 추가: if unsafe { unlinkat(dir.as_raw_fd(), name.as_ptr(), flags) } == 0 { | |
| 104 | 추가: Ok(()) | |
| 105 | 추가: } else { | |
| 106 | 추가: Err(io::Error::last_os_error()) | |
| 107 | 추가: } | |
| 108 | 추가: } | |
| 109 | 추가: | |
| 110 | 추가: fn open_directory(dir: &File, name: &CString) -> io::Result<File> { | |
| 111 | 추가: // 심볼릭 링크를 따르지 않고 폴더만 부모 핸들 기준으로 엶. | |
| 112 | 추가: let fd = unsafe { | |
| 113 | 추가: openat( | |
| 114 | 추가: dir.as_raw_fd(), | |
| 115 | 추가: name.as_ptr(), | |
| 116 | 추가: NOFOLLOW_DIRECTORY | CLOEXEC, | |
| 117 | 추가: ) | |
| 118 | 추가: }; | |
| 119 | 추가: if fd < 0 { | |
| 120 | 추가: return Err(io::Error::last_os_error()); | |
| 121 | 추가: } | |
| 122 | 추가: Ok(unsafe { File::from_raw_fd(fd) }) | |
| 123 | 추가: } | |
| 124 | 추가: | |
| 125 | 추가: fn remove_children(dir: &File, device: u64, depth: usize) -> io::Result<()> { | |
| 126 | 추가: let mut failure = None; | |
| 127 | 추가: for name in names(dir)? { | |
| 128 | 추가: if let Err(error) = remove_entry(dir, &name, device, depth) { | |
| 129 | 추가: if error.raw_os_error() != Some(ENOENT) { | |
| 130 | 추가: failure.get_or_insert(error); | |
| 131 | 추가: } | |
| 132 | 추가: } | |
| 133 | 추가: } | |
| 134 | 추가: failure.map_or(Ok(()), Err) | |
| 135 | 추가: } | |
| 136 | 추가: | |
| 137 | 추가: fn remove_entry(dir: &File, name: &CString, device: u64, depth: usize) -> io::Result<()> { | |
| 138 | 추가: match unlink(dir, name, 0) { | |
| 139 | 추가: Ok(()) => return Ok(()), | |
| 140 | 추가: Err(error) if matches!(error.raw_os_error(), Some(EISDIR | EPERM)) => {} | |
| 141 | 추가: Err(error) => return Err(error), | |
| 142 | 추가: } | |
| 143 | 추가: if depth >= MAX_DEPTH { | |
| 144 | 추가: return Err(io::Error::other("폴더가 너무 깊음")); | |
| 145 | 추가: } | |
| 146 | 추가: let child = match open_directory(dir, name) { | |
| 147 | 추가: Ok(child) => child, | |
| 148 | 추가: // 그 사이 폴더가 아닌 항목으로 바뀌었으면 항목 자체를 지움. | |
| 149 | 추가: Err(_) => return unlink(dir, name, 0), | |
| 150 | 추가: }; | |
| 151 | 추가: // 다른 파일 시스템이 연결된 폴더 안은 지우지 않음. | |
| 152 | 추가: if child.metadata()?.dev() != device { | |
| 153 | 추가: return Err(io::Error::other("다른 파일 시스템의 폴더")); | |
| 154 | 추가: } | |
| 155 | 추가: remove_children(&child, device, depth + 1)?; | |
| 156 | 추가: drop(child); | |
| 157 | 추가: unlink(dir, name, AT_REMOVEDIR) | |
| 158 | 추가: } | |
| 159 | 추가: } | |
| 160 | 추가: | |
| 161 | 추가: #[cfg(windows)] | |
| 162 | 추가: mod platform { | |
| 163 | 추가: use std::fs::{self, File}; | |
| 164 | 추가: use std::io; | |
| 165 | 추가: use std::path::Path; | |
| 166 | 추가: | |
| 167 | 추가: pub fn is_empty(_dir: &File, path: &Path) -> io::Result<bool> { | |
| 168 | 추가: // 호출한 쪽의 핸들이 이름 변경을 막고 있으므로 경로가 같은 폴더를 가리킴. | |
| 169 | 추가: Ok(fs::read_dir(path)?.next().is_none()) | |
| 170 | 추가: } | |
| 171 | 추가: | |
| 172 | 추가: pub fn remove_contents(_dir: &File, path: &Path) -> io::Result<()> { | |
| 173 | 추가: let mut failure = None; | |
| 174 | 추가: // 호출한 쪽의 핸들이 폴더 이름 변경을 막고 있으므로 경로가 같은 폴더를 가리킴. | |
| 175 | 추가: for entry in fs::read_dir(path)? { | |
| 176 | 추가: let result = entry.and_then(|entry| { | |
| 177 | 추가: let path = entry.path(); | |
| 178 | 추가: let kind = fs::symlink_metadata(&path)?.file_type(); | |
| 179 | 추가: if kind.is_symlink() { | |
| 180 | 추가: // 링크는 따라가지 않고 링크 자체만 지움. | |
| 181 | 추가: fs::remove_file(&path).or_else(|_| fs::remove_dir(&path)) | |
| 182 | 추가: } else if kind.is_dir() { | |
| 183 | 추가: fs::remove_dir_all(&path) | |
| 184 | 추가: } else { | |
| 185 | 추가: fs::remove_file(&path) | |
| 186 | 추가: } | |
| 187 | 추가: }); | |
| 188 | 추가: if let Err(error) = result { | |
| 189 | 추가: failure.get_or_insert(error); | |
| 190 | 추가: } | |
| 191 | 추가: } | |
| 192 | 추가: failure.map_or(Ok(()), Err) | |
| 193 | 추가: } | |
| 194 | 추가: } |
| @@ -1733,6 +1733,12 @@ dependencies = [ | ||
| 1733 | 1733 | "either", |
| 1734 | 1734 | ] |
| 1735 | 1735 | |
| 1736 | 추가: [[package]] | |
| 1737 | 추가: name = "itoa" | |
| 1738 | 추가: version = "1.0.19" | |
| 1739 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1740 | 추가: checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" | |
| 1741 | 추가: | |
| 1736 | 1742 | [[package]] |
| 1737 | 1743 | name = "jni" |
| 1738 | 1744 | version = "0.22.4" |
| @@ -3002,6 +3008,19 @@ dependencies = [ | ||
| 3002 | 3008 | "syn 3.0.10", |
| 3003 | 3009 | ] |
| 3004 | 3010 | |
| 3011 | 추가: [[package]] | |
| 3012 | 추가: name = "serde_json" | |
| 3013 | 추가: version = "1.0.154" | |
| 3014 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3015 | 추가: checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" | |
| 3016 | 추가: dependencies = [ | |
| 3017 | 추가: "itoa", | |
| 3018 | 추가: "memchr", | |
| 3019 | 추가: "serde", | |
| 3020 | 추가: "serde_core", | |
| 3021 | 추가: "zmij", | |
| 3022 | 추가: ] | |
| 3023 | 추가: | |
| 3005 | 3024 | [[package]] |
| 3006 | 3025 | name = "serde_repr" |
| 3007 | 3026 | version = "0.1.21" |
| @@ -4586,6 +4605,8 @@ dependencies = [ | ||
| 4586 | 4605 | "lzma-rust2", |
| 4587 | 4606 | "pbkdf2", |
| 4588 | 4607 | "png", |
| 4608 | 추가: "serde", | |
| 4609 | 추가: "serde_json", | |
| 4589 | 4610 | "sha1", |
| 4590 | 4611 | "sha2 0.10.9", |
| 4591 | 4612 | "subtle", |
| @@ -4621,6 +4642,12 @@ version = "0.6.8" | ||
| 4621 | 4642 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4622 | 4643 | checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" |
| 4623 | 4644 | |
| 4645 | 추가: [[package]] | |
| 4646 | 추가: name = "zmij" | |
| 4647 | 추가: version = "1.0.23" | |
| 4648 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4649 | 추가: checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" | |
| 4650 | 추가: | |
| 4624 | 4651 | [[package]] |
| 4625 | 4652 | name = "zune-core" |
| 4626 | 4653 | version = "0.5.3" |
| @@ -479,3 +479,233 @@ pub fn excluded_split(path: &Path) -> bool { | ||
| 479 | 479 | .to_ascii_lowercase(); |
| 480 | 480 | name.ends_with(".zip.001") || name.ends_with(".z01") || name.ends_with(".rar") |
| 481 | 481 | } |
| 482 | 추가: | |
| 483 | 추가: /// 같은 이름이 이미 있으면 `이름 (1)`, `이름 (2)`처럼 비어 있는 이름을 찾음. | |
| 484 | 추가: pub fn unique_folder(base: &Path) -> PathBuf { | |
| 485 | 추가: let taken = |path: &Path| fs::symlink_metadata(path).is_ok(); | |
| 486 | 추가: if !taken(base) { | |
| 487 | 추가: return base.to_path_buf(); | |
| 488 | 추가: } | |
| 489 | 추가: let name = base.file_name().unwrap_or_default().to_string_lossy(); | |
| 490 | 추가: (1..) | |
| 491 | 추가: .map(|n| base.with_file_name(format!("{name} ({n})"))) | |
| 492 | 추가: .find(|path| !taken(path)) | |
| 493 | 추가: .unwrap() | |
| 494 | 추가: } | |
| 495 | 추가: | |
| 496 | 추가: fn private_dir(path: &Path) -> io::Result<()> { | |
| 497 | 추가: let mut builder = fs::DirBuilder::new(); | |
| 498 | 추가: #[cfg(unix)] | |
| 499 | 추가: { | |
| 500 | 추가: use std::os::unix::fs::DirBuilderExt; | |
| 501 | 추가: builder.mode(0o700); | |
| 502 | 추가: } | |
| 503 | 추가: builder.create(path) | |
| 504 | 추가: } | |
| 505 | 추가: | |
| 506 | 추가: pub struct OpenRoot { | |
| 507 | 추가: path: PathBuf, | |
| 508 | 추가: handle: fs::File, | |
| 509 | 추가: identity: worker_protocol::protocol::SourceObject, | |
| 510 | 추가: } | |
| 511 | 추가: | |
| 512 | 추가: impl OpenRoot { | |
| 513 | 추가: fn capture(path: PathBuf) -> io::Result<Self> { | |
| 514 | 추가: let handle = open_root_handle(&path)?; | |
| 515 | 추가: // 만든 직후에는 비어 있어야 함. 만든 뒤 핸들을 잡기 전에 다른 폴더로 바뀌었다면 | |
| 516 | 추가: // 사용자 데이터가 들어 있을 수 있으므로 원본으로 기록하지 않음. | |
| 517 | 추가: if !worker_protocol::tree_remove::is_empty(&handle, &path)? { | |
| 518 | 추가: return Err(io::Error::other("만든 임시 폴더가 아님")); | |
| 519 | 추가: } | |
| 520 | 추가: let identity = worker_protocol::filesystem::object(&handle) | |
| 521 | 추가: .map_err(|_| io::Error::other("임시 폴더 식별 실패"))?; | |
| 522 | 추가: Ok(Self { | |
| 523 | 추가: path, | |
| 524 | 추가: handle, | |
| 525 | 추가: identity, | |
| 526 | 추가: }) | |
| 527 | 추가: } | |
| 528 | 추가: | |
| 529 | 추가: pub fn path(&self) -> &Path { | |
| 530 | 추가: &self.path | |
| 531 | 추가: } | |
| 532 | 추가: | |
| 533 | 추가: pub fn is_current(&self) -> bool { | |
| 534 | 추가: // 원본 핸들을 유지해 삭제된 inode가 재사용되어도 같다고 판정하지 않음. | |
| 535 | 추가: self.handle.metadata().is_ok() | |
| 536 | 추가: && open_root_handle(&self.path) | |
| 537 | 추가: .ok() | |
| 538 | 추가: .and_then(|file| worker_protocol::filesystem::object(&file).ok()) | |
| 539 | 추가: .is_some_and(|identity| identity == self.identity) | |
| 540 | 추가: } | |
| 541 | 추가: } | |
| 542 | 추가: | |
| 543 | 추가: fn open_root_handle(path: &Path) -> io::Result<fs::File> { | |
| 544 | 추가: let mut options = fs::OpenOptions::new(); | |
| 545 | 추가: options.read(true); | |
| 546 | 추가: #[cfg(target_os = "linux")] | |
| 547 | 추가: { | |
| 548 | 추가: use std::os::unix::fs::OpenOptionsExt; | |
| 549 | 추가: options.custom_flags(0x20000); // 심볼릭 링크를 따라가지 않음. | |
| 550 | 추가: } | |
| 551 | 추가: #[cfg(windows)] | |
| 552 | 추가: { | |
| 553 | 추가: use std::os::windows::fs::OpenOptionsExt; | |
| 554 | 추가: // 폴더 자체를 열며 재분석 지점을 따라가지 않음. | |
| 555 | 추가: // 삭제 공유를 허용하지 않아 열어 둔 동안 폴더 이름을 바꾸거나 지울 수 없게 함. | |
| 556 | 추가: options.share_mode(1 | 2).custom_flags(0x02000000 | 0x00200000); | |
| 557 | 추가: } | |
| 558 | 추가: let file = options.open(path)?; | |
| 559 | 추가: let metadata = file.metadata()?; | |
| 560 | 추가: if !metadata.is_dir() || fs::symlink_metadata(path)?.file_type().is_symlink() { | |
| 561 | 추가: return Err(io::Error::other("임시 폴더가 아님")); | |
| 562 | 추가: } | |
| 563 | 추가: #[cfg(windows)] | |
| 564 | 추가: { | |
| 565 | 추가: use std::os::windows::fs::MetadataExt; | |
| 566 | 추가: if metadata.file_attributes() & 0x400 != 0 { | |
| 567 | 추가: return Err(io::Error::other("재분석 지점은 임시 폴더로 쓰지 않음")); | |
| 568 | 추가: } | |
| 569 | 추가: } | |
| 570 | 추가: Ok(file) | |
| 571 | 추가: } | |
| 572 | 추가: | |
| 573 | 추가: /// 압축파일 안 파일을 기본 프로그램으로 열 때 쓸 임시 폴더를 만듦. | |
| 574 | 추가: /// 압축파일과 같은 폴더에 만들고, 그곳에 만들 수 없으면 시스템 임시 폴더를 씀. | |
| 575 | 추가: /// 숨김 폴더로 만들지 않음. snap으로 설치한 Firefox 등은 홈 바로 아래 숨김 폴더와 | |
| 576 | 추가: /// 시스템 임시 폴더의 파일을 읽지 못해 열기 요청을 조용히 무시함. | |
| 577 | 추가: pub fn create_open_root(archive: &Path) -> io::Result<OpenRoot> { | |
| 578 | 추가: create_open_root_with(archive, |_| {}) | |
| 579 | 추가: } | |
| 580 | 추가: | |
| 581 | 추가: /// `create_open_root`와 같고, 폴더를 만든 직후 핸들을 잡기 전에 `after_create`를 실행함. | |
| 582 | 추가: /// 만든 뒤 경로가 바뀌는 경우를 시험하려고 둠. | |
| 583 | 추가: /// 폴더를 만든 뒤 핸들을 잡기까지의 틈에 경로가 바뀌어도, 핸들로 확인한 폴더가 비어 있지 | |
| 584 | 추가: /// 않으면 원본으로 쓰지 않고 다른 이름으로 다시 만듦. 바뀐 폴더는 건드리지 않음. | |
| 585 | 추가: pub fn create_open_root_with( | |
| 586 | 추가: archive: &Path, | |
| 587 | 추가: mut after_create: impl FnMut(&Path), | |
| 588 | 추가: ) -> io::Result<OpenRoot> { | |
| 589 | 추가: let name = archive.file_name().unwrap_or_default().to_string_lossy(); | |
| 590 | 추가: let mut error = None; | |
| 591 | 추가: if let Some(parent) = archive.parent().filter(|p| !p.as_os_str().is_empty()) { | |
| 592 | 추가: let base = parent.join(open_root_name(&name)); | |
| 593 | 추가: for _ in 0..8 { | |
| 594 | 추가: let path = unique_folder(&base); | |
| 595 | 추가: match private_dir(&path) { | |
| 596 | 추가: Ok(()) => { | |
| 597 | 추가: after_create(&path); | |
| 598 | 추가: match OpenRoot::capture(path.clone()) { | |
| 599 | 추가: Ok(root) => return Ok(root), | |
| 600 | 추가: Err(e) => { | |
| 601 | 추가: // 비어 있는 폴더만 지워지므로 바뀐 폴더의 내용은 남음. | |
| 602 | 추가: let _ = fs::remove_dir(&path); | |
| 603 | 추가: error = Some(e); | |
| 604 | 추가: continue; | |
| 605 | 추가: } | |
| 606 | 추가: } | |
| 607 | 추가: } | |
| 608 | 추가: Err(e) if e.kind() == io::ErrorKind::AlreadyExists => continue, | |
| 609 | 추가: Err(e) => { | |
| 610 | 추가: error = Some(e); | |
| 611 | 추가: break; | |
| 612 | 추가: } | |
| 613 | 추가: } | |
| 614 | 추가: } | |
| 615 | 추가: } | |
| 616 | 추가: let base = std::env::temp_dir().join(format!("zipelo-{}-{name}", std::process::id())); | |
| 617 | 추가: let path = unique_folder(&base); | |
| 618 | 추가: private_dir(&path).map_err(|e| error.unwrap_or(e))?; | |
| 619 | 추가: after_create(&path); | |
| 620 | 추가: OpenRoot::capture(path.clone()).inspect_err(|_| { | |
| 621 | 추가: let _ = fs::remove_dir(&path); | |
| 622 | 추가: }) | |
| 623 | 추가: } | |
| 624 | 추가: | |
| 625 | 추가: /// 열기용 임시 폴더 이름. 예: `자료.zip (Zipelo 임시)`. | |
| 626 | 추가: pub fn open_root_name(archive_name: &str) -> String { | |
| 627 | 추가: format!("{archive_name} (Zipelo 임시)") | |
| 628 | 추가: } | |
| 629 | 추가: | |
| 630 | 추가: /// 이 앱이 만든 열기용 폴더를 지움. 다른 프로그램이 파일을 쓰고 있으면 남을 수 있음. | |
| 631 | 추가: pub fn remove_open_root(root: OpenRoot) { | |
| 632 | 추가: remove_open_root_with(root, || {}); | |
| 633 | 추가: } | |
| 634 | 추가: | |
| 635 | 추가: /// `remove_open_root`와 같고, 정체를 확인한 직후 삭제 전에 `after_check`를 실행함. | |
| 636 | 추가: /// 확인과 삭제 사이에 경로가 바뀌는 경우를 시험하려고 둠. | |
| 637 | 추가: /// 내용은 만들 때 열어 둔 폴더 핸들에 묶어 지우므로 경로가 바뀌어도 다른 폴더는 건드리지 않음. | |
| 638 | 추가: pub fn remove_open_root_with(root: OpenRoot, after_check: impl FnOnce()) { | |
| 639 | 추가: if !root.is_current() { | |
| 640 | 추가: return; | |
| 641 | 추가: } | |
| 642 | 추가: after_check(); | |
| 643 | 추가: let OpenRoot { path, handle, .. } = root; | |
| 644 | 추가: let _ = worker_protocol::tree_remove::remove_contents(&handle, &path); | |
| 645 | 추가: // Windows는 핸들을 닫아야 폴더를 지울 수 있음. | |
| 646 | 추가: drop(handle); | |
| 647 | 추가: // 비어 있지 않거나 링크로 바뀐 경로는 지워지지 않으므로 다른 내용이 사라지지 않음. | |
| 648 | 추가: let _ = fs::remove_dir(&path); | |
| 649 | 추가: } | |
| 650 | 추가: | |
| 651 | 추가: /// 기본 프로그램으로 열면 실행될 수 있는 파일은 바로 열지 않음. | |
| 652 | 추가: /// Windows는 스크립트도 연결 프로그램이 바로 실행하므로 범위가 넓고, | |
| 653 | 추가: /// Linux는 스크립트를 편집기로 열므로 실행·설치 파일만 막음. | |
| 654 | 추가: pub fn blocked_open(name: &str) -> bool { | |
| 655 | 추가: #[cfg(windows)] | |
| 656 | 추가: const EXECUTABLE: &[&str] = &[ | |
| 657 | 추가: "exe", "com", "bat", "cmd", "scr", "pif", "msi", "msp", "msc", "ps1", "psm1", "vbs", | |
| 658 | 추가: "vbe", "js", "jse", "wsf", "wsh", "hta", "cpl", "lnk", "url", "reg", "jar", "inf", "scf", | |
| 659 | 추가: "chm", "dll", "sys", "appref-ms", "application", "gadget", "settingcontent-ms", | |
| 660 | 추가: ]; | |
| 661 | 추가: #[cfg(not(windows))] | |
| 662 | 추가: const EXECUTABLE: &[&str] = &[ | |
| 663 | 추가: "desktop", "appimage", "run", "bin", "jar", "deb", "rpm", "snap", "flatpakref", | |
| 664 | 추가: "flatpak", "exe", "msi", | |
| 665 | 추가: ]; | |
| 666 | 추가: open_extension(name).is_some_and(|ext| EXECUTABLE.contains(&ext.to_ascii_lowercase().as_str())) | |
| 667 | 추가: } | |
| 668 | 추가: | |
| 669 | 추가: fn open_extension(name: &str) -> Option<&str> { | |
| 670 | 추가: let leaf = name.rsplit(['/', '\\']).next().unwrap_or(name); | |
| 671 | 추가: leaf.rsplit_once('.') | |
| 672 | 추가: .map(|(_, ext)| ext) | |
| 673 | 추가: .filter(|ext| !ext.is_empty()) | |
| 674 | 추가: } | |
| 675 | 추가: | |
| 676 | 추가: /// 실행 파일이라 열지 않았다는 짧은 안내. 압축은 풀지 않음. | |
| 677 | 추가: pub fn open_blocked_text(name: &str) -> String { | |
| 678 | 추가: match open_extension(name) { | |
| 679 | 추가: Some(ext) => format!("실행 파일(.{ext})은 안전을 위해 바로 열 수 없습니다"), | |
| 680 | 추가: None => "실행 파일은 안전을 위해 바로 열 수 없습니다".into(), | |
| 681 | 추가: } | |
| 682 | 추가: } | |
| 683 | 추가: | |
| 684 | 추가: pub const OPEN_FAILED: &str = "파일을 열 프로그램을 실행하지 못했습니다"; | |
| 685 | 추가: pub const OPEN_MISSING: &str = "풀린 파일을 찾지 못해 열지 못했습니다"; | |
| 686 | 추가: | |
| 687 | 추가: /// 운영체제에 설정된 기본 프로그램으로 파일을 엶. | |
| 688 | 추가: pub fn open_with_default(path: &Path) -> Result<(), String> { | |
| 689 | 추가: #[cfg(windows)] | |
| 690 | 추가: let mut command = { | |
| 691 | 추가: let mut command = std::process::Command::new("explorer.exe"); | |
| 692 | 추가: command.arg(path); | |
| 693 | 추가: command | |
| 694 | 추가: }; | |
| 695 | 추가: #[cfg(not(windows))] | |
| 696 | 추가: let mut command = { | |
| 697 | 추가: let mut command = std::process::Command::new("xdg-open"); | |
| 698 | 추가: command.arg(path); | |
| 699 | 추가: command | |
| 700 | 추가: }; | |
| 701 | 추가: command | |
| 702 | 추가: .stdin(std::process::Stdio::null()) | |
| 703 | 추가: .stdout(std::process::Stdio::null()) | |
| 704 | 추가: .stderr(std::process::Stdio::null()); | |
| 705 | 추가: let mut child = command.spawn().map_err(|_| OPEN_FAILED.to_owned())?; | |
| 706 | 추가: // 끝난 자식 프로세스를 거둬 좀비로 남지 않게 함. | |
| 707 | 추가: std::thread::spawn(move || { | |
| 708 | 추가: let _ = child.wait(); | |
| 709 | 추가: }); | |
| 710 | 추가: Ok(()) | |
| 711 | 추가: } |
| @@ -198,6 +198,24 @@ struct Marquee { | ||
| 198 | 198 | /// 파일 목록 한 행의 높이. 행 안의 크기 칸(theme::ROW)이 위아래 2px 여백으로 들어감. |
| 199 | 199 | const LIST_ROW: f32 = 36.0; |
| 200 | 200 | |
| 201 | 추가: /// 기본 프로그램으로 열려고 임시 폴더에 푸는 작업. 끝나면 원래 풀 위치로 되돌림. | |
| 202 | 추가: struct OpenRequest { | |
| 203 | 추가: folder: PathBuf, | |
| 204 | 추가: /// 풀린 뒤 열 파일의 압축파일 안 경로. 작업자는 새로 만든 상위 폴더도 출력으로 알리므로 | |
| 205 | 추가: /// 출력 목록에서 이 경로와 같은 항목을 찾아 엶. | |
| 206 | 추가: name: String, | |
| 207 | 추가: destination: PathBuf, | |
| 208 | 추가: automatic: bool, | |
| 209 | 추가: } | |
| 210 | 추가: | |
| 211 | 추가: /// 파일 목록의 오른쪽 클릭 메뉴에서 고른 동작. | |
| 212 | 추가: enum MenuAction { | |
| 213 | 추가: NewFolder, | |
| 214 | 추가: ChooseFolder, | |
| 215 | 추가: } | |
| 216 | 추가: | |
| 217 | 추가: type Opener = Box<dyn FnMut(&Path) -> Result<(), String>>; | |
| 218 | 추가: | |
| 201 | 219 | pub struct ArchiveApp { |
| 202 | 220 | pub model: Model, |
| 203 | 221 | factory: Box<dyn Factory>, |
| @@ -262,6 +280,13 @@ pub struct ArchiveApp { | ||
| 262 | 280 | checked_destination: bool, |
| 263 | 281 | ui_error: Option<String>, |
| 264 | 282 | initialized: bool, |
| 283 | 추가: opening: Option<OpenRequest>, | |
| 284 | 추가: /// 마지막 풀기가 기본 프로그램으로 열기였으면 그 항목. 다시 시도할 때 다시 엶. | |
| 285 | 추가: last_open: Option<u32>, | |
| 286 | 추가: /// 압축파일별 열기용 임시 폴더. 앱을 닫을 때 지움. | |
| 287 | 추가: open_roots: Vec<(PathBuf, present::OpenRoot)>, | |
| 288 | 추가: open_count: u64, | |
| 289 | 추가: opener: Opener, | |
| 265 | 290 | #[cfg(all(feature = "ui-fixture", debug_assertions))] |
| 266 | 291 | scenario_marquee: Option<egui::Rect>, |
| 267 | 292 | #[cfg(all(feature = "ui-fixture", debug_assertions))] |
| @@ -329,6 +354,11 @@ impl ArchiveApp { | ||
| 329 | 354 | checked_destination: false, |
| 330 | 355 | ui_error: None, |
| 331 | 356 | initialized: false, |
| 357 | 추가: opening: None, | |
| 358 | 추가: last_open: None, | |
| 359 | 추가: open_roots: Vec::new(), | |
| 360 | 추가: open_count: 0, | |
| 361 | 추가: opener: Box::new(present::open_with_default), | |
| 332 | 362 | #[cfg(all(feature = "ui-fixture", debug_assertions))] |
| 333 | 363 | scenario_marquee: None, |
| 334 | 364 | #[cfg(all(feature = "ui-fixture", debug_assertions))] |
| @@ -344,6 +374,131 @@ impl ArchiveApp { | ||
| 344 | 374 | self.dialogs = dialogs; |
| 345 | 375 | } |
| 346 | 376 | |
| 377 | 추가: /// 파일을 기본 프로그램으로 여는 방법을 바꿈. 시험에서 실제 프로그램 실행을 막을 때 씀. | |
| 378 | 추가: pub fn set_opener(&mut self, opener: Opener) { | |
| 379 | 추가: self.opener = opener; | |
| 380 | 추가: } | |
| 381 | 추가: | |
| 382 | 추가: /// 압축파일 안 파일 하나를 임시 폴더에 풀고 기본 프로그램으로 엶. | |
| 383 | 추가: pub fn open_entry(&mut self, entry_id: u32) -> bool { | |
| 384 | 추가: self.release_open(); | |
| 385 | 추가: if !self.model.can_extract() || self.opening.is_some() { | |
| 386 | 추가: return false; | |
| 387 | 추가: } | |
| 388 | 추가: let Some(entry) = self.model.entries.iter().find(|e| e.id == entry_id) else { | |
| 389 | 추가: return false; | |
| 390 | 추가: }; | |
| 391 | 추가: if entry.kind != Kind::File { | |
| 392 | 추가: return false; | |
| 393 | 추가: } | |
| 394 | 추가: let name = if self | |
| 395 | 추가: .model | |
| 396 | 추가: .list_id | |
| 397 | 추가: .as_ref() | |
| 398 | 추가: .is_some_and(|id| id.format == Format::Gzip) | |
| 399 | 추가: { | |
| 400 | 추가: self.gzip_name.clone() | |
| 401 | 추가: } else { | |
| 402 | 추가: entry.name.clone() | |
| 403 | 추가: }; | |
| 404 | 추가: if present::blocked_open(&name) { | |
| 405 | 추가: // 압축을 풀지 않고 바로 안내만 함. | |
| 406 | 추가: self.dismissed = false; | |
| 407 | 추가: self.ui_error = Some(present::open_blocked_text(&name)); | |
| 408 | 추가: return false; | |
| 409 | 추가: } | |
| 410 | 추가: let Some(archive) = self.model.archive.clone() else { | |
| 411 | 추가: return false; | |
| 412 | 추가: }; | |
| 413 | 추가: let root = match self.open_roots.iter().find(|(a, _)| *a == archive) { | |
| 414 | 추가: Some((_, root)) if root.is_current() => root.path().to_path_buf(), | |
| 415 | 추가: _ => match present::create_open_root(&archive) { | |
| 416 | 추가: Ok(root) => { | |
| 417 | 추가: self.open_roots.retain(|(a, _)| *a != archive); | |
| 418 | 추가: let path = root.path().to_path_buf(); | |
| 419 | 추가: self.open_roots.push((archive, root)); | |
| 420 | 추가: path | |
| 421 | 추가: } | |
| 422 | 추가: Err(_) => { | |
| 423 | 추가: self.dismissed = false; | |
| 424 | 추가: self.ui_error = Some(present::FOLDER_ERROR.into()); | |
| 425 | 추가: return false; | |
| 426 | 추가: } | |
| 427 | 추가: }, | |
| 428 | 추가: }; | |
| 429 | 추가: // 같은 파일을 여러 번 열어도 충돌하지 않도록 열 때마다 새 하위 폴더에 풂. | |
| 430 | 추가: self.open_count += 1; | |
| 431 | 추가: let folder = present::unique_folder(&root.join(self.open_count.to_string())); | |
| 432 | 추가: let request = OpenRequest { | |
| 433 | 추가: folder: folder.clone(), | |
| 434 | 추가: name: name.replace('\\', "/"), | |
| 435 | 추가: destination: std::mem::replace(&mut self.destination, folder), | |
| 436 | 추가: automatic: std::mem::replace(&mut self.automatic_destination, true), | |
| 437 | 추가: }; | |
| 438 | 추가: self.opening = Some(request); | |
| 439 | 추가: if self.extract_selection(Selection::EntryIds(vec![entry_id])) { | |
| 440 | 추가: self.last_open = Some(entry_id); | |
| 441 | 추가: true | |
| 442 | 추가: } else { | |
| 443 | 추가: self.finish_open(false); | |
| 444 | 추가: false | |
| 445 | 추가: } | |
| 446 | 추가: } | |
| 447 | 추가: | |
| 448 | 추가: /// 한도를 늘려 다시 시도할 수 있는 결과가 화면에 남아 있는 동안은 열기 상태를 유지함. | |
| 449 | 추가: fn open_retry_pending(&self) -> bool { | |
| 450 | 추가: self.opening.is_some() && !self.dismissed && self.model.can_retry_expanded() | |
| 451 | 추가: } | |
| 452 | 추가: | |
| 453 | 추가: /// 다시 시도를 기다리던 열기를 접고 원래 풀 위치로 되돌림. 다른 작업을 시작하기 전에 씀. | |
| 454 | 추가: fn release_open(&mut self) { | |
| 455 | 추가: if self.opening.is_some() && !self.model.busy() { | |
| 456 | 추가: self.finish_open(false); | |
| 457 | 추가: } | |
| 458 | 추가: } | |
| 459 | 추가: | |
| 460 | 추가: /// 열기용 풀기가 끝나면 원래 풀 위치를 되돌리고, 성공했으면 기본 프로그램을 실행함. | |
| 461 | 추가: fn finish_open(&mut self, completed: bool) { | |
| 462 | 추가: let Some(request) = self.opening.take() else { | |
| 463 | 추가: return; | |
| 464 | 추가: }; | |
| 465 | 추가: self.destination = request.destination; | |
| 466 | 추가: self.automatic_destination = request.automatic; | |
| 467 | 추가: if !completed { | |
| 468 | 추가: return; | |
| 469 | 추가: } | |
| 470 | 추가: let Some(name) = self | |
| 471 | 추가: .model | |
| 472 | 추가: .outputs | |
| 473 | 추가: .iter() | |
| 474 | 추가: .filter(|(_, d)| *d == Disposition::Created) | |
| 475 | 추가: .map(|(name, _)| name.replace('\\', "/")) | |
| 476 | 추가: .find(|name| name.trim_end_matches('/') == request.name) | |
| 477 | 추가: else { | |
| 478 | 추가: self.ui_error = Some(present::OPEN_MISSING.into()); | |
| 479 | 추가: return; | |
| 480 | 추가: }; | |
| 481 | 추가: let path = name | |
| 482 | 추가: .split('/') | |
| 483 | 추가: .fold(request.folder, |path, part| path.join(part)); | |
| 484 | 추가: match (self.opener)(&path) { | |
| 485 | 추가: // 결과 창 없이 바로 열린 파일을 보여 줌. | |
| 486 | 추가: Ok(()) => self.dismissed = true, | |
| 487 | 추가: Err(error) => self.ui_error = Some(error), | |
| 488 | 추가: } | |
| 489 | 추가: } | |
| 490 | 추가: | |
| 491 | 추가: /// 압축파일 이름으로 새 폴더를 만들고(같은 이름이 있으면 번호를 붙임) 선택 항목을 풂. | |
| 492 | 추가: fn extract_to_new_folder(&mut self) -> bool { | |
| 493 | 추가: self.release_open(); | |
| 494 | 추가: let Some(archive) = self.model.archive.clone() else { | |
| 495 | 추가: return false; | |
| 496 | 추가: }; | |
| 497 | 추가: self.destination = present::unique_folder(&present::default_destination(&archive)); | |
| 498 | 추가: self.automatic_destination = true; | |
| 499 | 추가: self.begin_extract() | |
| 500 | 추가: } | |
| 501 | 추가: | |
| 347 | 502 | /// 창 순서를 지정할 수 없는 환경에서는 부모 안에 작업 화면을 그림. |
| 348 | 503 | pub fn set_work_window_in_parent(&mut self, enabled: bool) { |
| 349 | 504 | self.work_in_parent = enabled; |
| @@ -469,6 +624,7 @@ impl ArchiveApp { | ||
| 469 | 624 | if self.model.busy() { |
| 470 | 625 | return; |
| 471 | 626 | } |
| 627 | 추가: self.release_open(); | |
| 472 | 628 | if self |
| 473 | 629 | .recovery_warning |
| 474 | 630 | .as_ref() |
| @@ -570,6 +726,7 @@ impl ArchiveApp { | ||
| 570 | 726 | } |
| 571 | 727 | |
| 572 | 728 | pub fn begin_extract(&mut self) -> bool { |
| 729 | 추가: self.release_open(); | |
| 573 | 730 | self.selected_only = !self.model.selected.is_empty(); |
| 574 | 731 | let selection = if self.selected_only { |
| 575 | 732 | Selection::EntryIds( |
| @@ -590,6 +747,9 @@ impl ArchiveApp { | ||
| 590 | 747 | return false; |
| 591 | 748 | } |
| 592 | 749 | self.selected_only = matches!(&selection, Selection::EntryIds(_)); |
| 750 | 추가: if self.opening.is_none() { | |
| 751 | 추가: self.last_open = None; | |
| 752 | 추가: } | |
| 593 | 753 | match present::prepare_destination(&self.destination, self.automatic_destination) { |
| 594 | 754 | Ok(true) => self.owned_destination = Some(self.destination.clone()), |
| 595 | 755 | Ok(false) => self.owned_destination = None, |
| @@ -688,6 +848,8 @@ impl ArchiveApp { | ||
| 688 | 848 | aes256: self.aes256, |
| 689 | 849 | } |
| 690 | 850 | }; |
| 851 | 추가: // 한도 초과 뒤 보류된 열기는 만들기와 무관하므로 시작 전에 접음. | |
| 852 | 추가: self.release_open(); | |
| 691 | 853 | if self.start(request) { |
| 692 | 854 | self.create = false; |
| 693 | 855 | self.create_win = WorkWindow::default(); |
| @@ -806,6 +968,9 @@ impl ArchiveApp { | ||
| 806 | 968 | } |
| 807 | 969 | } |
| 808 | 970 | Purpose::Destination | Purpose::Retry => { |
| 971 | 추가: // 다른 폴더를 골랐으면 기본 프로그램 열기가 아닌 일반 풀기로 다시 함. | |
| 972 | 추가: self.release_open(); | |
| 973 | 추가: self.last_open = None; | |
| 809 | 974 | self.choose_destination(path); |
| 810 | 975 | self.selected_only = !self.model.selected.is_empty(); |
| 811 | 976 | if purpose == Purpose::Retry { |
| @@ -862,6 +1027,9 @@ impl ArchiveApp { | ||
| 862 | 1027 | match request { |
| 863 | 1028 | Start::List { archive } => self.open_path(archive), |
| 864 | 1029 | Start::Preview { .. } | Start::RecoverZip { .. } => {} |
| 1030 | 추가: Start::Extract { .. } if let Some(entry_id) = self.last_open => { | |
| 1031 | 추가: self.open_entry(entry_id); | |
| 1032 | 추가: } | |
| 865 | 1033 | Start::Extract { |
| 866 | 1034 | selection, |
| 867 | 1035 | gzip_output_name, |
| @@ -918,6 +1086,20 @@ impl ArchiveApp { | ||
| 918 | 1086 | self.model.close = Close::Confirm; |
| 919 | 1087 | } |
| 920 | 1088 | if busy && !self.model.busy() { |
| 1089 | 추가: let completed = self.model.confirmed | |
| 1090 | 추가: && self | |
| 1091 | 추가: .model | |
| 1092 | 추가: .terminal | |
| 1093 | 추가: .as_ref() | |
| 1094 | 추가: .is_some_and(|t| t.outcome == Outcome::Completed); | |
| 1095 | 추가: if self.opening.is_some() { | |
| 1096 | 추가: // 열기용 폴더는 앱을 닫을 때 지우므로 풀 위치 소유 기록만 정리함. | |
| 1097 | 추가: self.owned_destination = None; | |
| 1098 | 추가: // 한도 실패는 늘려서 다시 시도할 수 있으므로 열기 상태를 남김. | |
| 1099 | 추가: if completed || !self.open_retry_pending() { | |
| 1100 | 추가: self.finish_open(completed); | |
| 1101 | 추가: } | |
| 1102 | 추가: } | |
| 921 | 1103 | if let Some(path) = self.owned_destination.take() { |
| 922 | 1104 | if !self.model.confirmed |
| 923 | 1105 | || self |
| @@ -930,6 +1112,10 @@ impl ArchiveApp { | ||
| 930 | 1112 | } |
| 931 | 1113 | } |
| 932 | 1114 | } |
| 1115 | 추가: if self.opening.is_some() && !self.model.busy() && !self.open_retry_pending() { | |
| 1116 | 추가: // 결과를 닫았거나 다시 시도할 수 없게 되었으면 원래 풀 위치로 되돌림. | |
| 1117 | 추가: self.finish_open(false); | |
| 1118 | 추가: } | |
| 933 | 1119 | } |
| 934 | 1120 | |
| 935 | 1121 | pub fn show(&mut self, root: &mut egui::Ui) { |
| @@ -1365,6 +1551,8 @@ impl ArchiveApp { | ||
| 1365 | 1551 | } |
| 1366 | 1552 | let mut focused = None; |
| 1367 | 1553 | let mut open = None; |
| 1554 | 추가: let mut open_file = None; | |
| 1555 | 추가: let mut menu_action = None; | |
| 1368 | 1556 | let mut next_offset = None; |
| 1369 | 1557 | let output = egui::ScrollArea::vertical() |
| 1370 | 1558 | .id_salt("archive-rows") |
| @@ -1386,7 +1574,12 @@ impl ArchiveApp { | ||
| 1386 | 1574 | && relative.x <= width |
| 1387 | 1575 | && relative.y >= 0.0 |
| 1388 | 1576 | && relative.y < rows.len() as f32 * LIST_ROW; |
| 1389 | 삭제: if clip.contains(press) && !in_row && ui.input(|i| i.pointer.primary_pressed()) | |
| 1577 | 추가: // 목록 위에 떠 있는 창(부모 안 작업 창 등)을 누른 경우는 목록 조작이 아님. | |
| 1578 | 추가: let on_list = ui.ctx().layer_id_at(press) == Some(ui.layer_id()); | |
| 1579 | 추가: if clip.contains(press) | |
| 1580 | 추가: && on_list | |
| 1581 | 추가: && !in_row | |
| 1582 | 추가: && ui.input(|i| i.pointer.primary_pressed()) | |
| 1390 | 1583 | { |
| 1391 | 1584 | background.request_focus(); |
| 1392 | 1585 | let ctrl = ui.input(|i| i.modifiers.ctrl || i.modifiers.command); |
| @@ -1499,8 +1692,26 @@ impl ArchiveApp { | ||
| 1499 | 1692 | modifiers.shift, |
| 1500 | 1693 | ); |
| 1501 | 1694 | } |
| 1502 | 삭제: if row.directory && response.double_clicked() { | |
| 1503 | 삭제: open = Some(row.path.clone()); | |
| 1695 | 추가: if response.double_clicked() { | |
| 1696 | 추가: if row.directory { | |
| 1697 | 추가: open = Some(row.path.clone()); | |
| 1698 | 추가: } else if let [id] = row.ids.iter().copied().collect::<Vec<_>>()[..] { | |
| 1699 | 추가: open_file = Some(id); | |
| 1700 | 추가: } | |
| 1701 | 추가: } | |
| 1702 | 추가: if active && response.secondary_clicked() && !selected { | |
| 1703 | 추가: // 선택하지 않은 행을 오른쪽 클릭하면 그 행만 선택한 뒤 메뉴를 엶. | |
| 1704 | 추가: self.select_row(&rows, index, false, false); | |
| 1705 | 추가: } | |
| 1706 | 추가: if active { | |
| 1707 | 추가: response.context_menu(|ui| { | |
| 1708 | 추가: if ui.button("압축 파일명으로 새 폴더를 만들어 압축 풀기").clicked() { | |
| 1709 | 추가: menu_action = Some(MenuAction::NewFolder); | |
| 1710 | 추가: } | |
| 1711 | 추가: if ui.button("특정 폴더에 압축 풀기").clicked() { | |
| 1712 | 추가: menu_action = Some(MenuAction::ChooseFolder); | |
| 1713 | 추가: } | |
| 1714 | 추가: }); | |
| 1504 | 1715 | } |
| 1505 | 1716 | // 암호가 걸린 항목은 이름 앞에 *를 붙이고, 툴팁은 실제 이름을 보여 줌. |
| 1506 | 1717 | let name = if row.encrypted { |
| @@ -1638,6 +1849,8 @@ impl ArchiveApp { | ||
| 1638 | 1849 | .min(rows.len() - 1); |
| 1639 | 1850 | if rows[index].directory { |
| 1640 | 1851 | open = Some(rows[index].path.clone()); |
| 1852 | 추가: } else if let [id] = rows[index].ids.iter().copied().collect::<Vec<_>>()[..] { | |
| 1853 | 추가: open_file = Some(id); | |
| 1641 | 1854 | } |
| 1642 | 1855 | } |
| 1643 | 1856 | } |
| @@ -1650,10 +1863,37 @@ impl ArchiveApp { | ||
| 1650 | 1863 | ); |
| 1651 | 1864 | } |
| 1652 | 1865 | } |
| 1866 | 추가: // 마우스 옆 버튼(뒤로)을 목록 위에서 누르면 상위 폴더로 이동함. | |
| 1867 | 추가: if active | |
| 1868 | 추가: && !self.folder.is_empty() | |
| 1869 | 추가: && ui.input(|i| { | |
| 1870 | 추가: i.pointer.button_pressed(egui::PointerButton::Extra1) | |
| 1871 | 추가: && i.pointer | |
| 1872 | 추가: .interact_pos() | |
| 1873 | 추가: .is_some_and(|pos| path_row.union(background.rect).contains(pos)) | |
| 1874 | 추가: }) | |
| 1875 | 추가: { | |
| 1876 | 추가: open = Some( | |
| 1877 | 추가: self.folder | |
| 1878 | 추가: .rsplit_once('/') | |
| 1879 | 추가: .map_or("", |(parent, _)| parent) | |
| 1880 | 추가: .to_owned(), | |
| 1881 | 추가: ); | |
| 1882 | 추가: } | |
| 1653 | 1883 | if let Some(folder) = open { |
| 1654 | 1884 | self.browse_folder(&folder); |
| 1655 | 1885 | background.request_focus(); |
| 1656 | 1886 | } |
| 1887 | 추가: if let Some(id) = open_file { | |
| 1888 | 추가: self.open_entry(id); | |
| 1889 | 추가: } | |
| 1890 | 추가: match menu_action { | |
| 1891 | 추가: Some(MenuAction::NewFolder) => { | |
| 1892 | 추가: self.extract_to_new_folder(); | |
| 1893 | 추가: } | |
| 1894 | 추가: Some(MenuAction::ChooseFolder) => self.open_picker(Purpose::Destination), | |
| 1895 | 추가: None => {} | |
| 1896 | 추가: } | |
| 1657 | 1897 | } |
| 1658 | 1898 | |
| 1659 | 1899 | fn clear_list_selection(&mut self) { |
| @@ -1966,9 +2206,13 @@ impl ArchiveApp { | ||
| 1966 | 2206 | }; |
| 1967 | 2207 | if self.work_in_parent { |
| 1968 | 2208 | // Wayland는 창 올리기를 지원하지 않으므로 부모 안에서 같은 내용을 그림. |
| 1969 | 삭제: let mut open = true; | |
| 1970 | 삭제: let mut window = egui::Window::new(RichText::new(title).size(theme::FONT_SMALL)) | |
| 2209 | 추가: // egui 기본 제목 줄의 닫기 버튼은 마우스를 올려도 모양이 바뀌지 않으므로 | |
| 2210 | 추가: // 제목 줄을 직접 그리고 별도 창과 같은 닫기 버튼을 씀. | |
| 2211 | 추가: let mut close = false; | |
| 2212 | 추가: let busy = self.model.busy(); | |
| 2213 | 추가: egui::Window::new(RichText::new(&title).size(theme::FONT_SMALL)) | |
| 1971 | 2214 | .id(egui::Id::new("archive-work-in-parent")) |
| 2215 | 추가: .title_bar(false) | |
| 1972 | 2216 | .default_pos( |
| 1973 | 2217 | ctx.content_rect().center() - egui::vec2(WORK_WIDTH, self.work.height) / 2.0, |
| 1974 | 2218 | ) |
| @@ -1980,21 +2224,26 @@ impl ArchiveApp { | ||
| 1980 | 2224 | .resizable(false) |
| 1981 | 2225 | .fade_in(false) |
| 1982 | 2226 | .fade_out(false) |
| 1983 | 삭제: .title_frame( | |
| 1984 | 삭제: theme::panel(theme::STRIPE) | |
| 1985 | 삭제: .inner_margin(egui::Margin::symmetric(16, 8)) | |
| 1986 | 삭제: .corner_radius(0), | |
| 1987 | 삭제: ) | |
| 1988 | 2227 | .frame( |
| 1989 | 삭제: theme::panel(theme::PANEL) | |
| 2228 | 추가: egui::Frame::new() | |
| 2229 | 추가: .fill(theme::PANEL) | |
| 1990 | 2230 | .stroke(egui::Stroke::new(1.0, theme::BORDER)) |
| 2231 | 추가: .inner_margin(egui::Margin::ZERO) | |
| 1991 | 2232 | .corner_radius(0), |
| 1992 | 삭제: ); | |
| 1993 | 삭제: if !self.model.busy() { | |
| 1994 | 삭제: window = window.open(&mut open); | |
| 1995 | 삭제: } | |
| 1996 | 삭제: window.show(ctx, |ui| self.work_area(ui)); | |
| 1997 | 삭제: if !open { | |
| 2233 | 추가: ) | |
| 2234 | 추가: .show(ctx, |ui| { | |
| 2235 | 추가: let spacing = ui.spacing().item_spacing.y; | |
| 2236 | 추가: ui.spacing_mut().item_spacing.y = 0.0; | |
| 2237 | 추가: close = window_frame::in_parent_title(ui, "work-in-parent", &title, !busy); | |
| 2238 | 추가: egui::Frame::new() | |
| 2239 | 추가: .inner_margin(egui::Margin::same(theme::PAD)) | |
| 2240 | 추가: .show(ui, |ui| { | |
| 2241 | 추가: ui.spacing_mut().item_spacing.y = spacing; | |
| 2242 | 추가: ui.set_width(WORK_WIDTH - 2.0 * theme::PAD as f32); | |
| 2243 | 추가: self.work_area(ui) | |
| 2244 | 추가: }); | |
| 2245 | 추가: }); | |
| 2246 | 추가: if close { | |
| 1998 | 2247 | self.dismissed = true; |
| 1999 | 2248 | self.ui_error = None; |
| 2000 | 2249 | self.model.input_error = None; |
| @@ -3435,5 +3684,8 @@ impl eframe::App for ArchiveApp { | ||
| 3435 | 3684 | impl Drop for ArchiveApp { |
| 3436 | 3685 | fn drop(&mut self) { |
| 3437 | 3686 | self.clear_password(); |
| 3687 | 추가: for (_, root) in self.open_roots.drain(..) { | |
| 3688 | 추가: present::remove_open_root(root); | |
| 3689 | 추가: } | |
| 3438 | 3690 | } |
| 3439 | 3691 | } |
| @@ -11,6 +11,7 @@ pub const TITLE_HEIGHT: f32 = 38.0; | ||
| 11 | 11 | const BUTTON_SIZE: Vec2 = egui::vec2(34.0, 26.0); |
| 12 | 12 | const RESIZE_EDGE: f32 = 6.0; |
| 13 | 13 | const DRAG_THRESHOLD: f32 = 4.0; |
| 14 | 추가: const IN_PARENT_TITLE: f32 = 36.0; | |
| 14 | 15 | const TITLE_BG: Color32 = Color32::from_rgb(235, 238, 242); |
| 15 | 16 | |
| 16 | 17 | /// 창 테두리를 직접 그려야 하는지 판단함. |
| @@ -113,6 +114,35 @@ pub fn title_bar(root: &mut egui::Ui, id: &str, title: &str, buttons: Buttons) - | ||
| 113 | 114 | moved |
| 114 | 115 | } |
| 115 | 116 | |
| 117 | 추가: /// 부모 창 안에 그리는 자식 창의 제목 줄. 닫기 버튼을 누르면 true를 돌려줌. | |
| 118 | 추가: /// 별도 창의 제목 표시줄과 같은 닫기 버튼(마우스를 올리면 빨간 배경)을 씀. | |
| 119 | 추가: pub fn in_parent_title(ui: &mut egui::Ui, id: &str, title: &str, closable: bool) -> bool { | |
| 120 | 추가: let width = ui.available_width(); | |
| 121 | 추가: let (rect, _) = ui.allocate_exact_size(egui::vec2(width, IN_PARENT_TITLE), Sense::hover()); | |
| 122 | 추가: let painter = ui.painter(); | |
| 123 | 추가: painter.rect_filled(rect, 0.0, theme::STRIPE); | |
| 124 | 추가: painter.hline( | |
| 125 | 추가: rect.x_range(), | |
| 126 | 추가: rect.bottom() - 0.5, | |
| 127 | 추가: Stroke::new(1.0, theme::BORDER), | |
| 128 | 추가: ); | |
| 129 | 추가: let button = Rect::from_center_size( | |
| 130 | 추가: egui::pos2(rect.right() - 6.0 - BUTTON_SIZE.x / 2.0, rect.center().y), | |
| 131 | 추가: BUTTON_SIZE, | |
| 132 | 추가: ); | |
| 133 | 추가: let reserved = if closable { BUTTON_SIZE.x + 12.0 } else { 0.0 }; | |
| 134 | 추가: let font = FontId::proportional(theme::FONT_SMALL); | |
| 135 | 추가: let text = fit(ui, title, &font, (rect.width() - 32.0 - reserved).max(0.0)); | |
| 136 | 추가: ui.painter().text( | |
| 137 | 추가: egui::pos2(rect.left() + 16.0, rect.center().y), | |
| 138 | 추가: Align2::LEFT_CENTER, | |
| 139 | 추가: text, | |
| 140 | 추가: font, | |
| 141 | 추가: theme::TEXT, | |
| 142 | 추가: ); | |
| 143 | 추가: closable && window_button(ui, id, button, Glyph::Close).clicked() | |
| 144 | 추가: } | |
| 145 | 추가: | |
| 116 | 146 | /// 제목 표시줄을 누른 채 움직였는지를 원시 입력으로 판단함. |
| 117 | 147 | /// 창 이동 중에는 운영체제가 마우스를 가져가서 버튼 놓기가 앱에 오지 않으므로, |
| 118 | 148 | /// egui의 끌기 상태에 기대면 다음 끌기가 시작되지 않음. |
| @@ -13,6 +13,10 @@ ROOT = Path(__file__).resolve().parents[1] | ||
| 13 | 13 | |
| 14 | 14 | # 미리보기 디코더는 MIT 조건을 선택하며 원문 고지를 함께 수집함. |
| 15 | 15 | LICENSE_CHOICES = { |
| 16 | 추가: # userdb 응답은 직접 파서를 만들지 않고 검증된 JSON 해석기를 사용함. | |
| 17 | 추가: ("serde", "1.0.229"): "MIT", | |
| 18 | 추가: ("serde_core", "1.0.229"): "MIT", | |
| 19 | 추가: ("serde_json", "1.0.154"): "MIT", | |
| 16 | 20 | ("png", "0.18.1"): "MIT", |
| 17 | 21 | ("zune-jpeg", "0.5.15"): "MIT", |
| 18 | 22 | ("zipelo-jpeg", "0.5.15"): "MIT", |
| @@ -0,0 +1,32 @@ | ||
| 1 | 추가: """userdb JSON 해석기의 배포 고지 원문을 검증함.""" | |
| 2 | 추가: | |
| 3 | 추가: import importlib.util | |
| 4 | 추가: from pathlib import Path | |
| 5 | 추가: import unittest | |
| 6 | 추가: | |
| 7 | 추가: ROOT = Path(__file__).resolve().parents[2] | |
| 8 | 추가: SPEC = importlib.util.spec_from_file_location("userdb_licenses", ROOT / "packaging/licenses.py") | |
| 9 | 추가: LICENSES = importlib.util.module_from_spec(SPEC) | |
| 10 | 추가: SPEC.loader.exec_module(LICENSES) | |
| 11 | 추가: | |
| 12 | 추가: | |
| 13 | 추가: class UserdbLicenses(unittest.TestCase): | |
| 14 | 추가: def test_json_dependencies_preserve_selected_mit_notices(self): | |
| 15 | 추가: records = LICENSES.inventory([ROOT / "experiments/rust-archive-worker/Cargo.toml"]) | |
| 16 | 추가: selected = {record["name"]: record for record in records} | |
| 17 | 추가: for name, version in [("serde", "1.0.229"), ("serde_core", "1.0.229"), ("serde_json", "1.0.154")]: | |
| 18 | 추가: with self.subTest(name=name): | |
| 19 | 추가: record = selected[name] | |
| 20 | 추가: self.assertEqual(record["version"], version) | |
| 21 | 추가: self.assertEqual(record["selected_license"], "MIT") | |
| 22 | 추가: self.assertIn("MIT", record["license"].split(" OR ")) | |
| 23 | 추가: self.assertTrue(record["files"]) | |
| 24 | 추가: notice = LICENSES.render([record]) | |
| 25 | 추가: for original in record["files"]: | |
| 26 | 추가: self.assertIn(original["text"], notice) | |
| 27 | 추가: self.assertIn(original["sha256"], notice) | |
| 28 | 추가: self.assertTrue({"itoa", "memchr", "zmij"}.issubset(selected)) | |
| 29 | 추가: | |
| 30 | 추가: | |
| 31 | 추가: if __name__ == "__main__": | |
| 32 | 추가: unittest.main() |
| @@ -200,6 +200,12 @@ dependencies = [ | ||
| 200 | 200 | "generic-array", |
| 201 | 201 | ] |
| 202 | 202 | |
| 203 | 추가: [[package]] | |
| 204 | 추가: name = "itoa" | |
| 205 | 추가: version = "1.0.19" | |
| 206 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 207 | 추가: checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" | |
| 208 | 추가: | |
| 203 | 209 | [[package]] |
| 204 | 210 | name = "libbz2-rs-sys" |
| 205 | 211 | version = "0.2.6" |
| @@ -221,6 +227,12 @@ dependencies = [ | ||
| 221 | 227 | "sha2 0.11.1", |
| 222 | 228 | ] |
| 223 | 229 | |
| 230 | 추가: [[package]] | |
| 231 | 추가: name = "memchr" | |
| 232 | 추가: version = "2.8.3" | |
| 233 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 234 | 추가: checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" | |
| 235 | 추가: | |
| 224 | 236 | [[package]] |
| 225 | 237 | name = "miniz_oxide" |
| 226 | 238 | version = "0.8.9" |
| @@ -264,6 +276,66 @@ dependencies = [ | ||
| 264 | 276 | "miniz_oxide 0.8.9", |
| 265 | 277 | ] |
| 266 | 278 | |
| 279 | 추가: [[package]] | |
| 280 | 추가: name = "proc-macro2" | |
| 281 | 추가: version = "1.0.107" | |
| 282 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 283 | 추가: checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" | |
| 284 | 추가: dependencies = [ | |
| 285 | 추가: "unicode-ident", | |
| 286 | 추가: ] | |
| 287 | 추가: | |
| 288 | 추가: [[package]] | |
| 289 | 추가: name = "quote" | |
| 290 | 추가: version = "1.0.47" | |
| 291 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 292 | 추가: checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" | |
| 293 | 추가: dependencies = [ | |
| 294 | 추가: "proc-macro2", | |
| 295 | 추가: ] | |
| 296 | 추가: | |
| 297 | 추가: [[package]] | |
| 298 | 추가: name = "serde" | |
| 299 | 추가: version = "1.0.229" | |
| 300 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 301 | 추가: checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" | |
| 302 | 추가: dependencies = [ | |
| 303 | 추가: "serde_core", | |
| 304 | 추가: ] | |
| 305 | 추가: | |
| 306 | 추가: [[package]] | |
| 307 | 추가: name = "serde_core" | |
| 308 | 추가: version = "1.0.229" | |
| 309 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 310 | 추가: checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" | |
| 311 | 추가: dependencies = [ | |
| 312 | 추가: "serde_derive", | |
| 313 | 추가: ] | |
| 314 | 추가: | |
| 315 | 추가: [[package]] | |
| 316 | 추가: name = "serde_derive" | |
| 317 | 추가: version = "1.0.229" | |
| 318 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 319 | 추가: checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" | |
| 320 | 추가: dependencies = [ | |
| 321 | 추가: "proc-macro2", | |
| 322 | 추가: "quote", | |
| 323 | 추가: "syn", | |
| 324 | 추가: ] | |
| 325 | 추가: | |
| 326 | 추가: [[package]] | |
| 327 | 추가: name = "serde_json" | |
| 328 | 추가: version = "1.0.154" | |
| 329 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 330 | 추가: checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" | |
| 331 | 추가: dependencies = [ | |
| 332 | 추가: "itoa", | |
| 333 | 추가: "memchr", | |
| 334 | 추가: "serde", | |
| 335 | 추가: "serde_core", | |
| 336 | 추가: "zmij", | |
| 337 | 추가: ] | |
| 338 | 추가: | |
| 267 | 339 | [[package]] |
| 268 | 340 | name = "sha1" |
| 269 | 341 | version = "0.10.7" |
| @@ -309,12 +381,29 @@ version = "2.6.1" | ||
| 309 | 381 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 310 | 382 | checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" |
| 311 | 383 | |
| 384 | 추가: [[package]] | |
| 385 | 추가: name = "syn" | |
| 386 | 추가: version = "3.0.10" | |
| 387 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 388 | 추가: checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" | |
| 389 | 추가: dependencies = [ | |
| 390 | 추가: "proc-macro2", | |
| 391 | 추가: "quote", | |
| 392 | 추가: "unicode-ident", | |
| 393 | 추가: ] | |
| 394 | 추가: | |
| 312 | 395 | [[package]] |
| 313 | 396 | name = "typenum" |
| 314 | 397 | version = "1.20.1" |
| 315 | 398 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 316 | 399 | checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" |
| 317 | 400 | |
| 401 | 추가: [[package]] | |
| 402 | 추가: name = "unicode-ident" | |
| 403 | 추가: version = "1.0.27" | |
| 404 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 405 | 추가: checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" | |
| 406 | 추가: | |
| 318 | 407 | [[package]] |
| 319 | 408 | name = "version_check" |
| 320 | 409 | version = "0.9.5" |
| @@ -337,6 +426,8 @@ dependencies = [ | ||
| 337 | 426 | "lzma-rust2", |
| 338 | 427 | "pbkdf2", |
| 339 | 428 | "png", |
| 429 | 추가: "serde", | |
| 430 | 추가: "serde_json", | |
| 340 | 431 | "sha1", |
| 341 | 432 | "sha2 0.10.9", |
| 342 | 433 | "subtle", |
| @@ -366,6 +457,12 @@ version = "0.6.8" | ||
| 366 | 457 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 367 | 458 | checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" |
| 368 | 459 | |
| 460 | 추가: [[package]] | |
| 461 | 추가: name = "zmij" | |
| 462 | 추가: version = "1.0.23" | |
| 463 | 추가: source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 464 | 추가: checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" | |
| 465 | 추가: | |
| 369 | 466 | [[package]] |
| 370 | 467 | name = "zune-core" |
| 371 | 468 | version = "0.5.3" |
| @@ -287,3 +287,56 @@ fn explorer_folder_click_and_escape_control_actual_extraction_scope() { | ||
| 287 | 287 | )); |
| 288 | 288 | assert_reaped(&observed); |
| 289 | 289 | } |
| 290 | 추가: | |
| 291 | 추가: // 작업자는 새로 만든 상위 폴더도 출력으로 알림. 하위 폴더 안 파일도 그 파일 자체를 열어야 함. | |
| 292 | 추가: #[test] | |
| 293 | 추가: fn double_click_open_extracts_nested_file_and_opens_that_file() { | |
| 294 | 추가: let scratch = Scratch::new(); | |
| 295 | 추가: let folder = make_directory(&scratch.path("site")); | |
| 296 | 추가: fs::write(folder.join("index.html"), b"<p>zipelo</p>").unwrap(); | |
| 297 | 추가: fs::write(folder.join("style.css"), b"p{}").unwrap(); | |
| 298 | 추가: let archive = scratch.path("site.zip"); | |
| 299 | 추가: let (factory, observed) = observed_factory(); | |
| 300 | 추가: let mut screen = Screen::new(factory); | |
| 301 | 추가: let opened = std::rc::Rc::new(std::cell::RefCell::new(Vec::new())); | |
| 302 | 추가: let record = opened.clone(); | |
| 303 | 추가: screen.app.set_opener(Box::new(move |path| { | |
| 304 | 추가: record.borrow_mut().push(path.to_path_buf()); | |
| 305 | 추가: Ok(()) | |
| 306 | 추가: })); | |
| 307 | 추가: screen.app.add_sources(vec![folder]); | |
| 308 | 추가: screen.render(vec![]); | |
| 309 | 추가: screen.set_text("zip-name", "site.zip"); | |
| 310 | 추가: screen.click("압축하기"); | |
| 311 | 추가: screen.settle(); | |
| 312 | 추가: screen.open(&archive); | |
| 313 | 추가: for name in ["site/index.html", "site/style.css"] { | |
| 314 | 추가: let id = screen | |
| 315 | 추가: .app | |
| 316 | 추가: .model | |
| 317 | 추가: .entries | |
| 318 | 추가: .iter() | |
| 319 | 추가: .find(|entry| entry.name == name) | |
| 320 | 추가: .unwrap() | |
| 321 | 추가: .id; | |
| 322 | 추가: assert!(screen.app.open_entry(id)); | |
| 323 | 추가: screen.settle(); | |
| 324 | 추가: screen.render(vec![]); | |
| 325 | 추가: } | |
| 326 | 추가: let root = scratch.path("site.zip (Zipelo 임시)"); | |
| 327 | 추가: assert_eq!( | |
| 328 | 추가: *opened.borrow(), | |
| 329 | 추가: vec![ | |
| 330 | 추가: root.join("1/site/index.html"), | |
| 331 | 추가: root.join("2/site/style.css") | |
| 332 | 추가: ] | |
| 333 | 추가: ); | |
| 334 | 추가: assert_eq!( | |
| 335 | 추가: fs::read(root.join("1/site/index.html")).unwrap(), | |
| 336 | 추가: b"<p>zipelo</p>" | |
| 337 | 추가: ); | |
| 338 | 추가: assert!(!root.join("1/site/style.css").exists()); | |
| 339 | 추가: assert_reaped(&observed); | |
| 340 | 추가: drop(screen); | |
| 341 | 추가: assert!(!root.exists()); | |
| 342 | 추가: } |
| @@ -3,6 +3,7 @@ struct Explorer { | ||
| 3 | 3 | ctx: egui::Context, |
| 4 | 4 | factory: FakeFactory, |
| 5 | 5 | time: f64, |
| 6 | 추가: opened: std::rc::Rc<std::cell::RefCell<Vec<PathBuf>>>, | |
| 6 | 7 | } |
| 7 | 8 | impl Explorer { |
| 8 | 9 | fn new(scratch: &Folder) -> Self { |
| @@ -25,11 +26,18 @@ impl Explorer { | ||
| 25 | 26 | encrypted: false, |
| 26 | 27 | }) |
| 27 | 28 | .into(); |
| 29 | 추가: let opened = std::rc::Rc::new(std::cell::RefCell::new(Vec::new())); | |
| 30 | 추가: let record = opened.clone(); | |
| 31 | 추가: app.set_opener(Box::new(move |path| { | |
| 32 | 추가: record.borrow_mut().push(path.to_path_buf()); | |
| 33 | 추가: Ok(()) | |
| 34 | 추가: })); | |
| 28 | 35 | let mut screen = Self { |
| 29 | 36 | app, |
| 30 | 37 | ctx: egui::Context::default(), |
| 31 | 38 | factory, |
| 32 | 39 | time: 0.0, |
| 40 | 추가: opened, | |
| 33 | 41 | }; |
| 34 | 42 | screen.frame(egui::Modifiers::NONE, vec![]); |
| 35 | 43 | screen.frame(egui::Modifiers::NONE, vec![]); |
| @@ -115,6 +123,44 @@ impl Explorer { | ||
| 115 | 123 | }], |
| 116 | 124 | ); |
| 117 | 125 | } |
| 126 | 추가: fn button(&mut self, point: egui::Pos2, button: egui::PointerButton) { | |
| 127 | 추가: self.time += 1.0; | |
| 128 | 추가: for pressed in [true, false] { | |
| 129 | 추가: self.frame( | |
| 130 | 추가: egui::Modifiers::NONE, | |
| 131 | 추가: vec![ | |
| 132 | 추가: egui::Event::PointerMoved(point), | |
| 133 | 추가: egui::Event::PointerButton { | |
| 134 | 추가: pos: point, | |
| 135 | 추가: button, | |
| 136 | 추가: pressed, | |
| 137 | 추가: modifiers: egui::Modifiers::NONE, | |
| 138 | 추가: }, | |
| 139 | 추가: ], | |
| 140 | 추가: ); | |
| 141 | 추가: } | |
| 142 | 추가: self.frame(egui::Modifiers::NONE, vec![]); | |
| 143 | 추가: } | |
| 144 | 추가: fn double_click(&mut self, path: &str) { | |
| 145 | 추가: self.time += 1.0; | |
| 146 | 추가: let point = self.row(path).center(); | |
| 147 | 추가: for _ in 0..2 { | |
| 148 | 추가: self.pointer(point, true, egui::Modifiers::NONE); | |
| 149 | 추가: self.pointer(point, false, egui::Modifiers::NONE); | |
| 150 | 추가: } | |
| 151 | 추가: for _ in 0..30 { | |
| 152 | 추가: self.frame(egui::Modifiers::NONE, vec![]); | |
| 153 | 추가: } | |
| 154 | 추가: } | |
| 155 | 추가: fn click_text(&mut self, label: &str) { | |
| 156 | 추가: let output = self.frame(egui::Modifiers::NONE, vec![]); | |
| 157 | 추가: let rect = layout_text(&output) | |
| 158 | 추가: .into_iter() | |
| 159 | 추가: .find(|(text, _, _)| text == label) | |
| 160 | 추가: .unwrap_or_else(|| panic!("{label} 없음")) | |
| 161 | 추가: .1; | |
| 162 | 추가: self.button(rect.center(), egui::PointerButton::Primary); | |
| 163 | 추가: } | |
| 118 | 164 | #[track_caller] |
| 119 | 165 | fn selected(&self, ids: &[u32]) { |
| 120 | 166 | assert_eq!(self.app.model.selected, ids.iter().copied().collect()); |
| @@ -222,16 +268,383 @@ fn explorer_keyboard_ranges_enter_backspace_and_escape_are_scoped_to_the_list() | ||
| 222 | 268 | } |
| 223 | 269 | |
| 224 | 270 | #[test] |
| 225 | 삭제: fn explorer_double_click_opens_only_folders_and_resets_selection() { | |
| 271 | 추가: fn explorer_double_click_opens_files_with_default_app_and_folders_in_place() { | |
| 226 | 272 | let scratch = Folder::new(); |
| 227 | 273 | let mut s = Explorer::new(&scratch); |
| 228 | 삭제: let point = s.row("alpha.txt").center(); | |
| 229 | 삭제: for _ in 0..2 { | |
| 230 | 삭제: s.pointer(point, true, egui::Modifiers::NONE); | |
| 231 | 삭제: s.pointer(point, false, egui::Modifiers::NONE); | |
| 274 | 추가: let destination = s.app.model.archive.clone().unwrap().with_file_name("sample"); | |
| 275 | 추가: // 실제 작업자처럼 새로 만든 상위 폴더도 출력으로 알림. | |
| 276 | 추가: s.factory.state.borrow_mut().outputs = Some(vec!["docs".into(), "docs/child.txt".into()]); | |
| 277 | 추가: s.app.browse_folder("docs"); | |
| 278 | 추가: s.double_click("docs/child.txt"); | |
| 279 | 추가: s.selected(&[0]); | |
| 280 | 추가: // 파일은 압축파일 옆 숨김 임시 폴더에 그 파일만 풀고 기본 프로그램으로 엶. | |
| 281 | 추가: let root = scratch.0.join("sample.zip (Zipelo 임시)"); | |
| 282 | 추가: { | |
| 283 | 추가: let state = s.factory.state.borrow(); | |
| 284 | 추가: assert_eq!(state.starts.len(), 2); | |
| 285 | 추가: let Start::Extract { | |
| 286 | 추가: destination: folder, | |
| 287 | 추가: selection, | |
| 288 | 추가: .. | |
| 289 | 추가: } = state.starts.last().unwrap() | |
| 290 | 추가: else { | |
| 291 | 추가: panic!("{:?}", state.starts.last()); | |
| 292 | 추가: }; | |
| 293 | 추가: assert_eq!(selection, &Selection::EntryIds(vec![0])); | |
| 294 | 추가: assert_eq!(folder, &root.join("1")); | |
| 232 | 295 | } |
| 233 | 삭제: s.selected(&[1]); | |
| 296 | 추가: assert_eq!( | |
| 297 | 추가: *s.opened.borrow(), | |
| 298 | 추가: vec![root.join("1").join("docs").join("child.txt")] | |
| 299 | 추가: ); | |
| 300 | 추가: let output = s.frame(egui::Modifiers::NONE, vec![]); | |
| 301 | 추가: assert!( | |
| 302 | 추가: !layout_text(&output) | |
| 303 | 추가: .iter() | |
| 304 | 추가: .any(|(text, _, _)| text == "작업 결과") | |
| 305 | 추가: ); | |
| 306 | 추가: // 같은 파일을 다시 열면 새 하위 폴더를 씀. | |
| 307 | 추가: s.double_click("docs/child.txt"); | |
| 308 | 추가: assert!(matches!( | |
| 309 | 추가: s.factory.state.borrow().starts.last(), | |
| 310 | 추가: Some(Start::Extract { destination, .. }) if destination == &root.join("2") | |
| 311 | 추가: )); | |
| 312 | 추가: assert_eq!(s.opened.borrow().len(), 2); | |
| 313 | 추가: // 열 파일이 출력에 없으면 조용히 넘어가지 않고 알림. | |
| 314 | 추가: s.factory.state.borrow_mut().outputs = Some(vec!["docs".into()]); | |
| 315 | 추가: s.double_click("docs/child.txt"); | |
| 316 | 추가: assert_eq!(s.opened.borrow().len(), 2); | |
| 317 | 추가: assert!( | |
| 318 | 추가: layout_text(&s.frame(egui::Modifiers::NONE, vec![])) | |
| 319 | 추가: .iter() | |
| 320 | 추가: .any(|(text, _, _)| text == "풀린 파일을 찾지 못해 열지 못했습니다") | |
| 321 | 추가: ); | |
| 322 | 추가: // 열기용 폴더는 압축파일 이름 폴더와 섞이지 않음. | |
| 323 | 추가: assert!(!destination.exists()); | |
| 324 | 추가: // 앱을 닫으면 열기용 폴더를 지움. | |
| 325 | 추가: assert!(root.is_dir()); | |
| 326 | 추가: drop(s); | |
| 327 | 추가: assert!(!root.exists()); | |
| 328 | 추가: } | |
| 329 | 추가: | |
| 330 | 추가: /// 열기용 풀기가 한도 초과로 실패한 상태까지 진행함. 결과 창을 그리는 문맥도 함께 돌려줌. | |
| 331 | 추가: fn double_click_open_hits_limit(s: &mut Explorer) -> egui::Context { | |
| 332 | 추가: s.factory.state.borrow_mut().manual = true; | |
| 333 | 추가: s.double_click("alpha.txt"); | |
| 334 | 추가: assert_eq!(s.factory.state.borrow().starts.len(), 2); | |
| 335 | 추가: finish_limit(s); | |
| 336 | 추가: let ctx = egui::Context::default(); | |
| 337 | 추가: ctx.set_embed_viewports(false); | |
| 338 | 추가: for _ in 0..12 { | |
| 339 | 추가: policy_render(&ctx, &mut s.app, vec![]); | |
| 340 | 추가: } | |
| 341 | 추가: assert!(s.app.model.can_retry_expanded()); | |
| 342 | 추가: assert!(s.opened.borrow().is_empty()); | |
| 343 | 추가: ctx | |
| 344 | 추가: } | |
| 345 | 추가: | |
| 346 | 추가: fn finish_limit(s: &mut Explorer) { | |
| 347 | 추가: { | |
| 348 | 추가: let mut worker = s.factory.state.borrow_mut(); | |
| 349 | 추가: worker.frame(Event::Accepted { encryption: false }); | |
| 350 | 추가: worker.frame(Event::Terminal(Terminal { | |
| 351 | 추가: outcome: Outcome::Failed, | |
| 352 | 추가: error: Some(ErrorCode::Limit), | |
| 353 | 추가: publication: Publication::None, | |
| 354 | 추가: created_count: 0, | |
| 355 | 추가: retained_partial_count: 0, | |
| 356 | 추가: durability: Durability::NotApplicable, | |
| 357 | 추가: cleanup: Cleanup::Complete, | |
| 358 | 추가: })); | |
| 359 | 추가: worker.queue.extend([ | |
| 360 | 추가: HostEvent::StdoutEof, | |
| 361 | 추가: HostEvent::StderrEof, | |
| 362 | 추가: HostEvent::Exited { success: true }, | |
| 363 | 추가: ]); | |
| 364 | 추가: } | |
| 365 | 추가: for _ in 0..30 { | |
| 366 | 추가: s.frame(egui::Modifiers::NONE, vec![]); | |
| 367 | 추가: } | |
| 368 | 추가: } | |
| 369 | 추가: | |
| 370 | 추가: #[test] | |
| 371 | 추가: fn explorer_open_keeps_pending_open_when_limit_retry_succeeds() { | |
| 372 | 추가: let scratch = Folder::new(); | |
| 373 | 추가: let mut s = Explorer::new(&scratch); | |
| 374 | 추가: let root = scratch.0.join("sample.zip (Zipelo 임시)"); | |
| 375 | 추가: let ctx = double_click_open_hits_limit(&mut s); | |
| 376 | 추가: policy_click(&ctx, &mut s.app, "한도를 늘려 다시 시도"); | |
| 377 | 추가: assert!(s.app.model.busy()); | |
| 378 | 추가: assert!(s.factory.state.borrow().expanded); | |
| 379 | 추가: assert!(matches!( | |
| 380 | 추가: s.factory.state.borrow().starts.last(), | |
| 381 | 추가: Some(Start::Extract { destination, .. }) if destination == &root.join("1") | |
| 382 | 추가: )); | |
| 383 | 추가: { | |
| 384 | 추가: let mut worker = s.factory.state.borrow_mut(); | |
| 385 | 추가: worker.frame(Event::Accepted { encryption: false }); | |
| 386 | 추가: worker.frame(Event::Output { | |
| 387 | 추가: entry_id: None, | |
| 388 | 추가: relative_name: "alpha.txt".into(), | |
| 389 | 추가: disposition: Disposition::Created, | |
| 390 | 추가: }); | |
| 391 | 추가: worker.finish(Outcome::Completed, Publication::Complete); | |
| 392 | 추가: } | |
| 393 | 추가: for _ in 0..30 { | |
| 394 | 추가: s.frame(egui::Modifiers::NONE, vec![]); | |
| 395 | 추가: } | |
| 396 | 추가: // 다시 시도가 성공하면 기본 프로그램이 열림. | |
| 397 | 추가: assert_eq!(*s.opened.borrow(), vec![root.join("1").join("alpha.txt")]); | |
| 398 | 추가: // 열기가 끝나면 풀 위치는 원래대로 돌아옴. | |
| 399 | 추가: s.factory.state.borrow_mut().manual = false; | |
| 400 | 추가: assert!(s.app.begin_extract()); | |
| 401 | 추가: assert!(matches!( | |
| 402 | 추가: s.factory.state.borrow().starts.last(), | |
| 403 | 추가: Some(Start::Extract { destination, .. }) if !destination.starts_with(&root) | |
| 404 | 추가: )); | |
| 405 | 추가: } | |
| 406 | 추가: | |
| 407 | 추가: #[test] | |
| 408 | 추가: fn explorer_open_restores_destination_when_limit_result_is_dismissed() { | |
| 409 | 추가: let scratch = Folder::new(); | |
| 410 | 추가: let mut s = Explorer::new(&scratch); | |
| 411 | 추가: let root = scratch.0.join("sample.zip (Zipelo 임시)"); | |
| 412 | 추가: let ctx = double_click_open_hits_limit(&mut s); | |
| 413 | 추가: policy_click(&ctx, &mut s.app, "확인"); | |
| 414 | 추가: for _ in 0..3 { | |
| 415 | 추가: policy_render(&ctx, &mut s.app, vec![]); | |
| 416 | 추가: } | |
| 417 | 추가: assert!(s.opened.borrow().is_empty()); | |
| 418 | 추가: s.factory.state.borrow_mut().manual = false; | |
| 419 | 추가: assert!(s.app.begin_extract()); | |
| 420 | 추가: let state = s.factory.state.borrow(); | |
| 421 | 추가: let Some(Start::Extract { destination, .. }) = state.starts.last() else { | |
| 422 | 추가: panic!("{:?}", state.starts.last()); | |
| 423 | 추가: }; | |
| 424 | 추가: assert_eq!(destination, &scratch.0.join("sample")); | |
| 425 | 추가: assert!(!destination.starts_with(&root)); | |
| 426 | 추가: } | |
| 427 | 추가: | |
| 428 | 추가: #[test] | |
| 429 | 추가: fn explorer_open_restores_destination_when_expanded_retry_fails_again() { | |
| 430 | 추가: let scratch = Folder::new(); | |
| 431 | 추가: let mut s = Explorer::new(&scratch); | |
| 432 | 추가: let ctx = double_click_open_hits_limit(&mut s); | |
| 433 | 추가: policy_click(&ctx, &mut s.app, "한도를 늘려 다시 시도"); | |
| 434 | 추가: assert!(s.app.model.busy()); | |
| 435 | 추가: finish_limit(&mut s); | |
| 436 | 추가: assert!(s.opened.borrow().is_empty()); | |
| 437 | 추가: assert!(!s.app.model.can_retry_expanded()); | |
| 438 | 추가: s.factory.state.borrow_mut().manual = false; | |
| 439 | 추가: assert!(s.app.begin_extract()); | |
| 440 | 추가: assert!(matches!( | |
| 441 | 추가: s.factory.state.borrow().starts.last(), | |
| 442 | 추가: Some(Start::Extract { destination, .. }) if destination == &scratch.0.join("sample") | |
| 443 | 추가: )); | |
| 444 | 추가: } | |
| 445 | 추가: | |
| 446 | 추가: #[test] | |
| 447 | 추가: fn explorer_open_pending_after_limit_is_dropped_when_zip_creation_starts() { | |
| 448 | 추가: let scratch = Folder::new(); | |
| 449 | 추가: let mut s = Explorer::new(&scratch); | |
| 450 | 추가: let root = scratch.0.join("sample.zip (Zipelo 임시)"); | |
| 451 | 추가: let _limit_ctx = double_click_open_hits_limit(&mut s); | |
| 452 | 추가: // 한도 초과 결과를 닫지 않고 폴더를 끌어 놓아 ZIP 만들기를 시작함. | |
| 453 | 추가: let folder = scratch.0.join("photos"); | |
| 454 | 추가: std::fs::create_dir_all(&folder).unwrap(); | |
| 455 | 추가: std::fs::write(folder.join("a.txt"), b"abc").unwrap(); | |
| 456 | 추가: s.app.add_sources(vec![folder]); | |
| 457 | 추가: let ctx = egui::Context::default(); | |
| 458 | 추가: policy_click(&ctx, &mut s.app, "압축하기"); | |
| 459 | 추가: assert!(s.app.model.busy()); | |
| 460 | 추가: assert!(matches!( | |
| 461 | 추가: s.factory.state.borrow().starts.last(), | |
| 462 | 추가: Some(Start::CreateZip { .. }) | |
| 463 | 추가: )); | |
| 464 | 추가: { | |
| 465 | 추가: let mut worker = s.factory.state.borrow_mut(); | |
| 466 | 추가: worker.frame(Event::Accepted { encryption: false }); | |
| 467 | 추가: worker.frame(Event::Output { | |
| 468 | 추가: entry_id: None, | |
| 469 | 추가: relative_name: "photos.zip".into(), | |
| 470 | 추가: disposition: Disposition::Created, | |
| 471 | 추가: }); | |
| 472 | 추가: worker.finish(Outcome::Completed, Publication::Complete); | |
| 473 | 추가: } | |
| 474 | 추가: for _ in 0..30 { | |
| 475 | 추가: s.frame(egui::Modifiers::NONE, vec![]); | |
| 476 | 추가: } | |
| 477 | 추가: // 만들기가 끝나도 이전 열기가 적용되지 않아 오류가 뜨지 않음. | |
| 478 | 추가: for _ in 0..3 { | |
| 479 | 추가: policy_render(&ctx, &mut s.app, vec![]); | |
| 480 | 추가: } | |
| 481 | 추가: let shown = policy_render(&ctx, &mut s.app, vec![]); | |
| 482 | 추가: assert!( | |
| 483 | 추가: !shown.iter().any(|(text, _)| text.contains("열지 못했습니다")), | |
| 484 | 추가: "{shown:?}" | |
| 485 | 추가: ); | |
| 486 | 추가: assert!(s.opened.borrow().is_empty()); | |
| 487 | 추가: // 풀 위치도 원래대로 돌아옴. | |
| 488 | 추가: s.factory.state.borrow_mut().manual = false; | |
| 489 | 추가: assert!(s.app.begin_extract()); | |
| 490 | 추가: let state = s.factory.state.borrow(); | |
| 491 | 추가: let Some(Start::Extract { destination, .. }) = state.starts.last() else { | |
| 492 | 추가: panic!("{:?}", state.starts.last()); | |
| 493 | 추가: }; | |
| 494 | 추가: assert_eq!(destination, &scratch.0.join("sample")); | |
| 495 | 추가: assert!(!destination.starts_with(&root)); | |
| 496 | 추가: } | |
| 497 | 추가: | |
| 498 | 추가: #[test] | |
| 499 | 추가: fn explorer_double_click_does_not_open_executables() { | |
| 500 | 추가: let scratch = Folder::new(); | |
| 501 | 추가: let mut s = Explorer::new(&scratch); | |
| 502 | 추가: s.app.model.entries[2].name = "setup.EXE".into(); | |
| 503 | 추가: s.double_click("setup.EXE"); | |
| 234 | 504 | assert_eq!(s.factory.state.borrow().starts.len(), 1); |
| 505 | 추가: assert!(s.opened.borrow().is_empty()); | |
| 506 | 추가: let output = s.frame(egui::Modifiers::NONE, vec![]); | |
| 507 | 추가: assert!( | |
| 508 | 추가: layout_text(&output) | |
| 509 | 추가: .iter() | |
| 510 | 추가: .any(|(text, _, _)| text == "실행 파일(.EXE)은 안전을 위해 바로 열 수 없습니다") | |
| 511 | 추가: ); | |
| 512 | 추가: // 실행 파일은 압축을 풀지 않으므로 임시 폴더도 만들지 않음. | |
| 513 | 추가: assert!(!scratch.0.join("sample.zip (Zipelo 임시)").exists()); | |
| 514 | 추가: } | |
| 515 | 추가: | |
| 516 | 추가: #[test] | |
| 517 | 추가: fn explorer_dragging_in_parent_work_window_does_not_select_rows() { | |
| 518 | 추가: let scratch = Folder::new(); | |
| 519 | 추가: let mut s = Explorer::new(&scratch); | |
| 520 | 추가: s.app.set_work_window_in_parent(true); | |
| 521 | 추가: s.app.model.entries[2].name = "setup.EXE".into(); | |
| 522 | 추가: s.double_click("setup.EXE"); | |
| 523 | 추가: s.selected(&[2]); | |
| 524 | 추가: let close = s | |
| 525 | 추가: .ctx | |
| 526 | 추가: .read_response(egui::Id::unique(("window-button", "work-in-parent", "닫기"))) | |
| 527 | 추가: .expect("부모 안 작업 창") | |
| 528 | 추가: .rect; | |
| 529 | 추가: // 행이 하나뿐인 폴더로 옮겨 작업 창 제목 줄 아래가 목록의 빈 곳이 되게 함. | |
| 530 | 추가: s.app.browse_folder("docs"); | |
| 531 | 추가: let row = s.row("docs/child.txt"); | |
| 532 | 추가: s.selected(&[]); | |
| 533 | 추가: // 작업 창 제목 줄을 누르고 목록 행 위로 끌어도 목록 선택 사각형이 생기지 않아야 함. | |
| 534 | 추가: let start = egui::pos2(close.left() - 120.0, close.center().y); | |
| 535 | 추가: assert!(start.y > row.bottom(), "{start:?} {row:?}"); | |
| 536 | 추가: s.pointer(start, true, egui::Modifiers::NONE); | |
| 537 | 추가: let end = egui::pos2(row.center().x, row.center().y); | |
| 538 | 추가: for step in 1..=6 { | |
| 539 | 추가: let t = step as f32 / 6.0; | |
| 540 | 추가: s.frame( | |
| 541 | 추가: egui::Modifiers::NONE, | |
| 542 | 추가: vec![egui::Event::PointerMoved(start + (end - start) * t)], | |
| 543 | 추가: ); | |
| 544 | 추가: } | |
| 545 | 추가: let output = s.frame(egui::Modifiers::NONE, vec![]); | |
| 546 | 추가: s.selected(&[]); | |
| 547 | 추가: assert!(!output.shapes.iter().any(|shape| matches!( | |
| 548 | 추가: &shape.shape, | |
| 549 | 추가: egui::epaint::Shape::Rect(rect) if rect.fill == theme_blue_fill() | |
| 550 | 추가: ))); | |
| 551 | 추가: s.pointer(end, false, egui::Modifiers::NONE); | |
| 552 | 추가: s.selected(&[]); | |
| 553 | 추가: } | |
| 554 | 추가: | |
| 555 | 추가: fn theme_blue_fill() -> egui::Color32 { | |
| 556 | 추가: zipelo_ui_memory_app::archive_theme::BLUE.gamma_multiply(0.16) | |
| 557 | 추가: } | |
| 558 | 추가: | |
| 559 | 추가: #[test] | |
| 560 | 추가: fn explorer_context_menu_extracts_selection_into_numbered_archive_folder() { | |
| 561 | 추가: let scratch = Folder::new(); | |
| 562 | 추가: let mut s = Explorer::new(&scratch); | |
| 563 | 추가: fs::create_dir(scratch.0.join("sample")).unwrap(); | |
| 564 | 추가: s.click("alpha.txt", egui::Modifiers::NONE); | |
| 565 | 추가: // 선택하지 않은 행을 오른쪽 클릭하면 그 행만 선택하고 메뉴를 엶. | |
| 566 | 추가: let point = s.row("docs").center(); | |
| 567 | 추가: s.button(point, egui::PointerButton::Secondary); | |
| 568 | 추가: s.selected(&[0, 5]); | |
| 569 | 추가: s.click_text("압축 파일명으로 새 폴더를 만들어 압축 풀기"); | |
| 570 | 추가: for _ in 0..30 { | |
| 571 | 추가: s.frame(egui::Modifiers::NONE, vec![]); | |
| 572 | 추가: } | |
| 573 | 추가: let state = s.factory.state.borrow(); | |
| 574 | 추가: let Some(Start::Extract { | |
| 575 | 추가: destination, | |
| 576 | 추가: selection, | |
| 577 | 추가: .. | |
| 578 | 추가: }) = state.starts.last() | |
| 579 | 추가: else { | |
| 580 | 추가: panic!("{:?}", state.starts.last()); | |
| 581 | 추가: }; | |
| 582 | 추가: assert_eq!(destination, &scratch.0.join("sample (1)")); | |
| 583 | 추가: assert_eq!(selection, &Selection::EntryIds(vec![0, 5])); | |
| 584 | 추가: assert!(scratch.0.join("sample (1)").is_dir()); | |
| 585 | 추가: assert!(s.opened.borrow().is_empty()); | |
| 586 | 추가: } | |
| 587 | 추가: | |
| 588 | 추가: #[test] | |
| 589 | 추가: fn explorer_context_menu_asks_for_folder_and_extracts_only_selection() { | |
| 590 | 추가: let scratch = Folder::new(); | |
| 591 | 추가: let mut s = Explorer::new(&scratch); | |
| 592 | 추가: let dialogs = crate::dialogs::TestDialogs::default(); | |
| 593 | 추가: let target = scratch.0.join("target"); | |
| 594 | 추가: fs::create_dir(&target).unwrap(); | |
| 595 | 추가: dialogs | |
| 596 | 추가: .0 | |
| 597 | 추가: .borrow_mut() | |
| 598 | 추가: .answers | |
| 599 | 추가: .push_back(Some(vec![target.clone()])); | |
| 600 | 추가: s.app.set_dialogs(Box::new(dialogs.clone())); | |
| 601 | 추가: s.click("alpha.txt", egui::Modifiers::NONE); | |
| 602 | 추가: s.click("beta.txt", explorer_ctrl()); | |
| 603 | 추가: let point = s.row("beta.txt").center(); | |
| 604 | 추가: s.button(point, egui::PointerButton::Secondary); | |
| 605 | 추가: s.selected(&[1, 2]); | |
| 606 | 추가: s.click_text("특정 폴더에 압축 풀기"); | |
| 607 | 추가: for _ in 0..30 { | |
| 608 | 추가: s.frame(egui::Modifiers::NONE, vec![]); | |
| 609 | 추가: } | |
| 610 | 추가: assert_eq!( | |
| 611 | 추가: dialogs.0.borrow().requests.last().unwrap().purpose, | |
| 612 | 추가: zipelo_ui_memory_app::archive_dialog::Purpose::Destination | |
| 613 | 추가: ); | |
| 614 | 추가: assert!(matches!( | |
| 615 | 추가: s.factory.state.borrow().starts.last(), | |
| 616 | 추가: Some(Start::Extract { destination, selection: Selection::EntryIds(ids), .. }) | |
| 617 | 추가: if destination == &target && ids == &vec![1, 2] | |
| 618 | 추가: )); | |
| 619 | 추가: } | |
| 620 | 추가: | |
| 621 | 추가: #[test] | |
| 622 | 추가: fn explorer_mouse_back_button_goes_to_parent_folder() { | |
| 623 | 추가: let scratch = Folder::new(); | |
| 624 | 추가: let mut s = Explorer::new(&scratch); | |
| 625 | 추가: s.app.browse_folder("docs"); | |
| 626 | 추가: let point = s.row("docs/child.txt").center(); | |
| 627 | 추가: s.button(point, egui::PointerButton::Extra2); | |
| 628 | 추가: assert!(s.ctx.read_response(egui::Id::unique(("archive-row", "docs/child.txt"))).is_some()); | |
| 629 | 추가: s.button(point, egui::PointerButton::Extra1); | |
| 630 | 추가: assert!( | |
| 631 | 추가: layout_text(&s.frame(egui::Modifiers::NONE, vec![])) | |
| 632 | 추가: .iter() | |
| 633 | 추가: .any(|(text, _, _)| text == "alpha.txt") | |
| 634 | 추가: ); | |
| 635 | 추가: // 최상위에서는 아무 일도 하지 않음. | |
| 636 | 추가: s.button(point, egui::PointerButton::Extra1); | |
| 637 | 추가: assert!( | |
| 638 | 추가: layout_text(&s.frame(egui::Modifiers::NONE, vec![])) | |
| 639 | 추가: .iter() | |
| 640 | 추가: .any(|(text, _, _)| text == "alpha.txt") | |
| 641 | 추가: ); | |
| 642 | 추가: } | |
| 643 | 추가: | |
| 644 | 추가: #[test] | |
| 645 | 추가: fn explorer_double_click_opens_only_folders_and_resets_selection() { | |
| 646 | 추가: let scratch = Folder::new(); | |
| 647 | 추가: let mut s = Explorer::new(&scratch); | |
| 235 | 648 | s.time += 1.0; |
| 236 | 649 | let point = s.row("docs").center(); |
| 237 | 650 | for _ in 0..2 { |
| @@ -18,6 +18,8 @@ pub struct State { | ||
| 18 | 18 | pub list_format: Option<Format>, |
| 19 | 19 | pub fail_start: bool, |
| 20 | 20 | pub dropped_connections: usize, |
| 21 | 추가: /// 풀기 출력으로 알릴 이름. 없으면 "읽어주세요.txt" 하나를 알림. | |
| 22 | 추가: pub outputs: Option<Vec<String>>, | |
| 21 | 23 | pause: bool, |
| 22 | 24 | } |
| 23 | 25 | #[derive(Default, Clone)] |
| @@ -132,11 +134,17 @@ impl State { | ||
| 132 | 134 | total: Some(31), |
| 133 | 135 | completed_entries: 1, |
| 134 | 136 | }); |
| 135 | 삭제: self.frame(Event::Output { | |
| 136 | 삭제: entry_id: Some(0), | |
| 137 | 삭제: relative_name: "읽어주세요.txt".into(), | |
| 138 | 삭제: disposition: Disposition::Created, | |
| 139 | 삭제: }); | |
| 137 | 추가: let names = self | |
| 138 | 추가: .outputs | |
| 139 | 추가: .clone() | |
| 140 | 추가: .unwrap_or_else(|| vec!["읽어주세요.txt".into()]); | |
| 141 | 추가: for name in names { | |
| 142 | 추가: self.frame(Event::Output { | |
| 143 | 추가: entry_id: None, | |
| 144 | 추가: relative_name: name, | |
| 145 | 추가: disposition: Disposition::Created, | |
| 146 | 추가: }); | |
| 147 | 추가: } | |
| 140 | 148 | self.finish(Outcome::Completed, Publication::Complete); |
| 141 | 149 | } |
| 142 | 150 | } |
| @@ -333,6 +333,21 @@ fn default_names_and_middle_truncation_preserve_unicode() { | ||
| 333 | 333 | assert_eq!(default_destination(&path(name)), path("압축 해제")); |
| 334 | 334 | } |
| 335 | 335 | assert_eq!(default_destination(&path("자료.zip")), path("자료")); |
| 336 | 추가: assert!(blocked_open("폴더/setup.EXE")); | |
| 337 | 추가: // desktop 항목은 Linux 차단 목록에만 있음. | |
| 338 | 추가: #[cfg(not(windows))] | |
| 339 | 추가: assert!(blocked_open("run.desktop")); | |
| 340 | 추가: assert!(!blocked_open("사진.jpg")); | |
| 341 | 추가: assert!(!blocked_open("exe")); | |
| 342 | 추가: // Linux는 스크립트를 편집기로 열므로 막지 않음. | |
| 343 | 추가: #[cfg(not(windows))] | |
| 344 | 추가: assert!(!blocked_open("app.js")); | |
| 345 | 추가: #[cfg(windows)] | |
| 346 | 추가: assert!(blocked_open("app.js")); | |
| 347 | 추가: assert_eq!( | |
| 348 | 추가: open_blocked_text("폴더/setup.EXE"), | |
| 349 | 추가: "실행 파일(.EXE)은 안전을 위해 바로 열 수 없습니다" | |
| 350 | 추가: ); | |
| 336 | 351 | assert_eq!(middle_text("가나다라마바사아자차", 7), "가나다…아자차"); |
| 337 | 352 | assert_eq!(bytes_text(21), "21 B"); |
| 338 | 353 | } |
| @@ -358,6 +373,17 @@ impl Drop for Folder { | ||
| 358 | 373 | } |
| 359 | 374 | } |
| 360 | 375 | |
| 376 | 추가: #[test] | |
| 377 | 추가: fn unique_folder_numbers_existing_names() { | |
| 378 | 추가: let scratch = Folder::new(); | |
| 379 | 추가: let base = scratch.0.join("자료"); | |
| 380 | 추가: assert_eq!(unique_folder(&base), base); | |
| 381 | 추가: fs::create_dir(&base).unwrap(); | |
| 382 | 추가: assert_eq!(unique_folder(&base), scratch.0.join("자료 (1)")); | |
| 383 | 추가: fs::write(scratch.0.join("자료 (1)"), b"").unwrap(); | |
| 384 | 추가: assert_eq!(unique_folder(&base), scratch.0.join("자료 (2)")); | |
| 385 | 추가: } | |
| 386 | 추가: | |
| 361 | 387 | #[test] |
| 362 | 388 | fn automatic_destination_creation_and_failure_are_distinct() { |
| 363 | 389 | let scratch = Folder::new(); |
| @@ -1132,3 +1158,190 @@ fn client_protocol_errors_hide_internal_terms_but_preserve_exit_uncertainty() { | ||
| 1132 | 1158 | UNCONFIRMED_FINISH |
| 1133 | 1159 | ); |
| 1134 | 1160 | } |
| 1161 | 추가: | |
| 1162 | 추가: #[cfg(feature = "ui")] | |
| 1163 | 추가: #[cfg(unix)] | |
| 1164 | 추가: #[test] | |
| 1165 | 추가: fn app_exit_preserves_replaced_open_root() { | |
| 1166 | 추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp; | |
| 1167 | 추가: let scratch = Folder::new(); | |
| 1168 | 추가: let mut app = ArchiveApp::new( | |
| 1169 | 추가: Box::new(FakeFactory::default()), | |
| 1170 | 추가: Some(scratch.0.join("sample.zip")), | |
| 1171 | 추가: false, | |
| 1172 | 추가: ); | |
| 1173 | 추가: pump(&mut app.model); | |
| 1174 | 추가: assert!(app.open_entry(0)); | |
| 1175 | 추가: let root = scratch.0.join(open_root_name("sample.zip")); | |
| 1176 | 추가: fs::rename(&root, scratch.0.join("original")).unwrap(); | |
| 1177 | 추가: fs::create_dir(&root).unwrap(); | |
| 1178 | 추가: let retained = root.join("keep.txt"); | |
| 1179 | 추가: fs::write(&retained, b"user data").unwrap(); | |
| 1180 | 추가: drop(app); | |
| 1181 | 추가: assert_eq!(fs::read(retained).unwrap(), b"user data"); | |
| 1182 | 추가: } | |
| 1183 | 추가: | |
| 1184 | 추가: #[cfg(feature = "ui")] | |
| 1185 | 추가: #[test] | |
| 1186 | 추가: fn app_exit_removes_original_open_root() { | |
| 1187 | 추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp; | |
| 1188 | 추가: let scratch = Folder::new(); | |
| 1189 | 추가: let mut app = ArchiveApp::new( | |
| 1190 | 추가: Box::new(FakeFactory::default()), | |
| 1191 | 추가: Some(scratch.0.join("sample.zip")), | |
| 1192 | 추가: false, | |
| 1193 | 추가: ); | |
| 1194 | 추가: pump(&mut app.model); | |
| 1195 | 추가: assert!(app.open_entry(0)); | |
| 1196 | 추가: let root = scratch.0.join(open_root_name("sample.zip")); | |
| 1197 | 추가: fs::write(root.join("opened.txt"), b"temporary").unwrap(); | |
| 1198 | 추가: drop(app); | |
| 1199 | 추가: assert!(!root.exists()); | |
| 1200 | 추가: } | |
| 1201 | 추가: | |
| 1202 | 추가: #[cfg(feature = "ui")] | |
| 1203 | 추가: #[cfg(windows)] | |
| 1204 | 추가: #[test] | |
| 1205 | 추가: fn open_root_cannot_be_renamed_while_app_holds_it() { | |
| 1206 | 추가: use zipelo_ui_memory_app::archive_screen::ArchiveApp; | |
| 1207 | 추가: let scratch = Folder::new(); | |
| 1208 | 추가: let mut app = ArchiveApp::new( | |
| 1209 | 추가: Box::new(FakeFactory::default()), | |
| 1210 | 추가: Some(scratch.0.join("sample.zip")), | |
| 1211 | 추가: false, | |
| 1212 | 추가: ); | |
| 1213 | 추가: pump(&mut app.model); | |
| 1214 | 추가: assert!(app.open_entry(0)); | |
| 1215 | 추가: let root = scratch.0.join(open_root_name("sample.zip")); | |
| 1216 | 추가: // 열어 둔 핸들이 이름 변경을 막아 경로가 다른 폴더로 바뀌지 않음. | |
| 1217 | 추가: assert!(fs::rename(&root, scratch.0.join("original")).is_err()); | |
| 1218 | 추가: drop(app); | |
| 1219 | 추가: assert!(!root.exists()); | |
| 1220 | 추가: } | |
| 1221 | 추가: | |
| 1222 | 추가: #[cfg(unix)] | |
| 1223 | 추가: fn open_root_with_contents(scratch: &Folder) -> (OpenRoot, PathBuf) { | |
| 1224 | 추가: let root = create_open_root(&scratch.0.join("sample.zip")).unwrap(); | |
| 1225 | 추가: let path = root.path().to_path_buf(); | |
| 1226 | 추가: fs::create_dir_all(path.join("a/b")).unwrap(); | |
| 1227 | 추가: fs::write(path.join("a/b/deep.txt"), b"temporary").unwrap(); | |
| 1228 | 추가: fs::write(path.join("top.txt"), b"temporary").unwrap(); | |
| 1229 | 추가: (root, path) | |
| 1230 | 추가: } | |
| 1231 | 추가: | |
| 1232 | 추가: #[cfg(unix)] | |
| 1233 | 추가: #[test] | |
| 1234 | 추가: fn removal_is_bound_to_checked_folder_when_replaced_after_check() { | |
| 1235 | 추가: let scratch = Folder::new(); | |
| 1236 | 추가: let (root, path) = open_root_with_contents(&scratch); | |
| 1237 | 추가: let original = scratch.0.join("original"); | |
| 1238 | 추가: remove_open_root_with(root, || { | |
| 1239 | 추가: fs::rename(&path, &original).unwrap(); | |
| 1240 | 추가: fs::create_dir(&path).unwrap(); | |
| 1241 | 추가: fs::write(path.join("keep.txt"), b"user data").unwrap(); | |
| 1242 | 추가: }); | |
| 1243 | 추가: assert_eq!(fs::read(path.join("keep.txt")).unwrap(), b"user data"); | |
| 1244 | 추가: // 확인한 폴더의 내용만 지움. | |
| 1245 | 추가: assert_eq!(fs::read_dir(&original).unwrap().count(), 0); | |
| 1246 | 추가: } | |
| 1247 | 추가: | |
| 1248 | 추가: #[cfg(unix)] | |
| 1249 | 추가: #[test] | |
| 1250 | 추가: fn removal_does_not_follow_link_swapped_in_after_check() { | |
| 1251 | 추가: let scratch = Folder::new(); | |
| 1252 | 추가: let (root, path) = open_root_with_contents(&scratch); | |
| 1253 | 추가: let victim = scratch.0.join("victim"); | |
| 1254 | 추가: fs::create_dir(&victim).unwrap(); | |
| 1255 | 추가: fs::write(victim.join("keep.txt"), b"user data").unwrap(); | |
| 1256 | 추가: let original = scratch.0.join("original"); | |
| 1257 | 추가: remove_open_root_with(root, || { | |
| 1258 | 추가: fs::rename(&path, &original).unwrap(); | |
| 1259 | 추가: std::os::unix::fs::symlink(&victim, &path).unwrap(); | |
| 1260 | 추가: }); | |
| 1261 | 추가: assert_eq!(fs::read(victim.join("keep.txt")).unwrap(), b"user data"); | |
| 1262 | 추가: assert!(fs::symlink_metadata(&path).unwrap().file_type().is_symlink()); | |
| 1263 | 추가: assert_eq!(fs::read_dir(&original).unwrap().count(), 0); | |
| 1264 | 추가: } | |
| 1265 | 추가: | |
| 1266 | 추가: #[cfg(unix)] | |
| 1267 | 추가: #[test] | |
| 1268 | 추가: fn removal_does_not_follow_links_inside_folder() { | |
| 1269 | 추가: let scratch = Folder::new(); | |
| 1270 | 추가: let (root, path) = open_root_with_contents(&scratch); | |
| 1271 | 추가: let victim = scratch.0.join("victim"); | |
| 1272 | 추가: fs::create_dir(&victim).unwrap(); | |
| 1273 | 추가: fs::write(victim.join("keep.txt"), b"user data").unwrap(); | |
| 1274 | 추가: std::os::unix::fs::symlink(&victim, path.join("a/link")).unwrap(); | |
| 1275 | 추가: std::os::unix::fs::symlink(victim.join("keep.txt"), path.join("file-link")).unwrap(); | |
| 1276 | 추가: remove_open_root(root); | |
| 1277 | 추가: assert!(!path.exists()); | |
| 1278 | 추가: assert_eq!(fs::read(victim.join("keep.txt")).unwrap(), b"user data"); | |
| 1279 | 추가: } | |
| 1280 | 추가: | |
| 1281 | 추가: #[cfg(unix)] | |
| 1282 | 추가: #[test] | |
| 1283 | 추가: fn removal_of_original_folder_clears_nested_contents() { | |
| 1284 | 추가: let scratch = Folder::new(); | |
| 1285 | 추가: let (root, path) = open_root_with_contents(&scratch); | |
| 1286 | 추가: remove_open_root(root); | |
| 1287 | 추가: assert!(!path.exists()); | |
| 1288 | 추가: } | |
| 1289 | 추가: | |
| 1290 | 추가: #[cfg(unix)] | |
| 1291 | 추가: #[test] | |
| 1292 | 추가: fn creation_does_not_adopt_folder_replaced_before_handle_is_taken() { | |
| 1293 | 추가: let scratch = Folder::new(); | |
| 1294 | 추가: let archive = scratch.0.join("sample.zip"); | |
| 1295 | 추가: let swapped = scratch.0.join(open_root_name("sample.zip")); | |
| 1296 | 추가: let original = scratch.0.join("original"); | |
| 1297 | 추가: let mut swaps = 0; | |
| 1298 | 추가: let root = create_open_root_with(&archive, |path| { | |
| 1299 | 추가: swaps += 1; | |
| 1300 | 추가: if swaps == 1 { | |
| 1301 | 추가: fs::rename(path, &original).unwrap(); | |
| 1302 | 추가: fs::create_dir(path).unwrap(); | |
| 1303 | 추가: fs::write(path.join("keep.txt"), b"user data").unwrap(); | |
| 1304 | 추가: } | |
| 1305 | 추가: }) | |
| 1306 | 추가: .unwrap(); | |
| 1307 | 추가: // 바뀐 폴더는 원본으로 기록하지 않고 다른 이름의 새 폴더를 씀. | |
| 1308 | 추가: assert_ne!(root.path(), swapped); | |
| 1309 | 추가: assert!(root.is_current()); | |
| 1310 | 추가: remove_open_root(root); | |
| 1311 | 추가: assert_eq!(fs::read(swapped.join("keep.txt")).unwrap(), b"user data"); | |
| 1312 | 추가: } | |
| 1313 | 추가: | |
| 1314 | 추가: #[cfg(unix)] | |
| 1315 | 추가: #[test] | |
| 1316 | 추가: fn creation_does_not_adopt_link_replaced_before_handle_is_taken() { | |
| 1317 | 추가: let scratch = Folder::new(); | |
| 1318 | 추가: let archive = scratch.0.join("sample.zip"); | |
| 1319 | 추가: let link = scratch.0.join(open_root_name("sample.zip")); | |
| 1320 | 추가: let victim = scratch.0.join("victim"); | |
| 1321 | 추가: fs::create_dir(&victim).unwrap(); | |
| 1322 | 추가: fs::write(victim.join("keep.txt"), b"user data").unwrap(); | |
| 1323 | 추가: let mut swaps = 0; | |
| 1324 | 추가: let root = create_open_root_with(&archive, |path| { | |
| 1325 | 추가: swaps += 1; | |
| 1326 | 추가: if swaps == 1 { | |
| 1327 | 추가: fs::remove_dir(path).unwrap(); | |
| 1328 | 추가: std::os::unix::fs::symlink(&victim, path).unwrap(); | |
| 1329 | 추가: } | |
| 1330 | 추가: }) | |
| 1331 | 추가: .unwrap(); | |
| 1332 | 추가: assert_ne!(root.path(), link); | |
| 1333 | 추가: remove_open_root(root); | |
| 1334 | 추가: assert_eq!(fs::read(victim.join("keep.txt")).unwrap(), b"user data"); | |
| 1335 | 추가: assert!(fs::symlink_metadata(&link).unwrap().file_type().is_symlink()); | |
| 1336 | 추가: } | |
| 1337 | 추가: | |
| 1338 | 추가: #[test] | |
| 1339 | 추가: fn creation_of_unchanged_folder_is_empty_and_current() { | |
| 1340 | 추가: let scratch = Folder::new(); | |
| 1341 | 추가: let root = create_open_root(&scratch.0.join("sample.zip")).unwrap(); | |
| 1342 | 추가: let path = root.path().to_path_buf(); | |
| 1343 | 추가: assert!(root.is_current()); | |
| 1344 | 추가: assert_eq!(fs::read_dir(&path).unwrap().count(), 0); | |
| 1345 | 추가: remove_open_root(root); | |
| 1346 | 추가: assert!(!path.exists()); | |
| 1347 | 추가: } |
| @@ -938,3 +938,86 @@ fn scenario_window_hosting_survives_platform_frame_configuration() { | ||
| 938 | 938 | } |
| 939 | 939 | } |
| 940 | 940 | } |
| 941 | 추가: | |
| 942 | 추가: #[test] | |
| 943 | 추가: fn hosted_work_window_close_button_shows_hover_and_dismisses_result() { | |
| 944 | 추가: let factory = FakeFactory::manual(); | |
| 945 | 추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), Some("/sample.zip".into()), false); | |
| 946 | 추가: app.set_work_window_in_parent(true); | |
| 947 | 추가: let ctx = egui::Context::default(); | |
| 948 | 추가: ctx.set_embed_viewports(false); | |
| 949 | 추가: install_work_child_renderer(); | |
| 950 | 추가: { | |
| 951 | 추가: let mut worker = factory.state.borrow_mut(); | |
| 952 | 추가: worker.finish(Outcome::Failed, Publication::None); | |
| 953 | 추가: for event in &mut worker.queue { | |
| 954 | 추가: if let HostEvent::Frame { | |
| 955 | 추가: event: Event::Terminal(terminal), | |
| 956 | 추가: .. | |
| 957 | 추가: } = event | |
| 958 | 추가: { | |
| 959 | 추가: terminal.error = Some(ErrorCode::Io); | |
| 960 | 추가: } | |
| 961 | 추가: } | |
| 962 | 추가: } | |
| 963 | 추가: let render = |app: &mut ArchiveApp, events: Vec<egui::Event>| { | |
| 964 | 추가: let mut output = ctx.run_ui( | |
| 965 | 추가: egui::RawInput { | |
| 966 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 967 | 추가: egui::Pos2::ZERO, | |
| 968 | 추가: egui::vec2(1060.0, 720.0), | |
| 969 | 추가: )), | |
| 970 | 추가: events, | |
| 971 | 추가: ..Default::default() | |
| 972 | 추가: }, | |
| 973 | 추가: |ui| app.show(ui), | |
| 974 | 추가: ); | |
| 975 | 추가: output.textures_delta.clear(); | |
| 976 | 추가: output | |
| 977 | 추가: }; | |
| 978 | 추가: for _ in 0..4 { | |
| 979 | 추가: render(&mut app, vec![]); | |
| 980 | 추가: } | |
| 981 | 추가: let close_id = egui::Id::unique(("window-button", "work-in-parent", "닫기")); | |
| 982 | 추가: let close = ctx.read_response(close_id).expect("닫기 버튼").rect; | |
| 983 | 추가: let red = egui::Color32::from_rgb(232, 17, 35); | |
| 984 | 추가: fn has_fill(shapes: &[egui::epaint::ClippedShape], color: egui::Color32) -> bool { | |
| 985 | 추가: fn walk(shape: &Shape, color: egui::Color32) -> bool { | |
| 986 | 추가: match shape { | |
| 987 | 추가: Shape::Rect(rect) => rect.fill == color, | |
| 988 | 추가: Shape::Vec(shapes) => shapes.iter().any(|s| walk(s, color)), | |
| 989 | 추가: _ => false, | |
| 990 | 추가: } | |
| 991 | 추가: } | |
| 992 | 추가: shapes.iter().any(|s| walk(&s.shape, color)) | |
| 993 | 추가: } | |
| 994 | 추가: let idle = render(&mut app, vec![egui::Event::PointerMoved(egui::pos2(5.0, 5.0))]); | |
| 995 | 추가: assert!(!has_fill(&idle.shapes, red)); | |
| 996 | 추가: assert!( | |
| 997 | 추가: labels(&idle.shapes) | |
| 998 | 추가: .iter() | |
| 999 | 추가: .any(|(text, _)| text == "압축파일을 열지 못했습니다") | |
| 1000 | 추가: ); | |
| 1001 | 추가: render(&mut app, vec![egui::Event::PointerMoved(close.center())]); | |
| 1002 | 추가: let hovered = render(&mut app, vec![]); | |
| 1003 | 추가: assert!(has_fill(&hovered.shapes, red)); | |
| 1004 | 추가: for pressed in [true, false] { | |
| 1005 | 추가: render( | |
| 1006 | 추가: &mut app, | |
| 1007 | 추가: vec![egui::Event::PointerButton { | |
| 1008 | 추가: pos: close.center(), | |
| 1009 | 추가: button: egui::PointerButton::Primary, | |
| 1010 | 추가: pressed, | |
| 1011 | 추가: modifiers: egui::Modifiers::NONE, | |
| 1012 | 추가: }], | |
| 1013 | 추가: ); | |
| 1014 | 추가: } | |
| 1015 | 추가: render(&mut app, vec![]); | |
| 1016 | 추가: let shown = labels(&render(&mut app, vec![]).shapes); | |
| 1017 | 추가: assert!( | |
| 1018 | 추가: !shown | |
| 1019 | 추가: .iter() | |
| 1020 | 추가: .any(|(text, _)| text == "압축파일을 열지 못했습니다"), | |
| 1021 | 추가: "{shown:?}" | |
| 1022 | 추가: ); | |
| 1023 | 추가: } |
| @@ -523,6 +523,15 @@ fn symlink_parent_escape_is_rejected() { | ||
| 523 | 523 | assert_eq!(fs::read_dir(s.0.join("outside")).unwrap().count(), 0); |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 추가: // 개인 그룹의 압축 해제만 허용하고 공유 쓰기는 거부함. | |
| 527 | 추가: #[cfg(target_os = "linux")] | |
| 528 | 추가: #[test] | |
| 529 | 추가: fn private_group_writable_output_is_accepted() { | |
| 530 | 추가: private_group::check_extraction("personal", true); | |
| 531 | 추가: private_group::check_extraction("shared-primary", false); | |
| 532 | 추가: private_group::check_extraction("world-writable", false); | |
| 533 | 추가: } | |
| 534 | 추가: | |
| 526 | 535 | #[test] |
| 527 | 536 | fn changed_source_is_reopen_error_before_decode() { |
| 528 | 537 | let s = Scratch::new(); |
| @@ -1611,3 +1620,6 @@ mod spool_location; | ||
| 1611 | 1620 | |
| 1612 | 1621 | #[cfg(target_os = "linux")] |
| 1613 | 1622 | mod spool_fallback; |
| 1623 | 추가: | |
| 1624 | 추가: #[cfg(target_os = "linux")] | |
| 1625 | 추가: mod private_group; |
Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기