{"record":{"id":"cf262867374dad76","repo":"BigPizzaV3/CodexPlusPlus","slug":"32-mib-zip","errorCode":null,"errorMessage":"主题包必须是 32 MiB 以内的普通 ZIP 文件","messagePattern":"主题包必须是 32 MiB 以内的普通 ZIP 文件","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_community.rs","lineNumber":201,"sourceCode":"        || validated.manifest.version != metadata.version\n    {\n        bail!(\"DreamSkin 主题包身份与审核元数据不一致\");\n    }\n    crate::dream_skin_library::save_validated_dream_skin_package(state_dir, &validated)\n}\n\npub fn import_theme_package(\n    state_dir: &Path,\n    archive_path: &Path,\n) -> anyhow::Result<DreamSkinThemeSummary> {\n    let metadata = std::fs::symlink_metadata(archive_path)\n        .with_context(|| format!(\"无法读取主题包：{}\", archive_path.display()))?;\n    if !metadata.file_type().is_file()\n        || metadata.file_type().is_symlink()\n        || metadata.len() == 0\n        || metadata.len() as usize > PACKAGE_BYTES_LIMIT\n    {\n        bail!(\"主题包必须是 32 MiB 以内的普通 ZIP 文件\");\n    }\n    let bytes = std::fs::read(archive_path)\n        .with_context(|| format!(\"无法读取主题包：{}\", archive_path.display()))?;\n    let validated = crate::dream_skin_package::validate_and_read_package(\n        &bytes,\n        if cfg!(windows) { \"windows\" } else { \"macos\" },\n    )?;\n    crate::dream_skin_library::save_validated_dream_skin_package(state_dir, &validated)\n}\n\npub fn save_pending_community_link(url: &str) -> anyhow::Result<String> {\n    let version_id = version_id_from_link(url)?;\n    let path = pending_link_path();\n    if let Some(parent) = path.parent() {\n        std::fs::create_dir_all(parent)?;\n    }\n    crate::settings::atomic_write(\n        &path,","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_community.rs#L183-L219","documentation":"import_theme_package rejects any archive that is not a regular, non-empty, non-symlink file of at most PACKAGE_BYTES_LIMIT (32 MiB). The check runs on symlink_metadata before reading the file, guarding against symlink trickery, directories, and oversized payloads. This is a size/type gate applied before the ZIP is validated and parsed.","triggerScenarios":"Calling import_theme_package with archive_path pointing at: a directory, a symlink, an empty file, a file larger than 32 MiB, or a special (non-regular) file.","commonSituations":"User picks the wrong file in a file dialog (e.g. a folder or a .zip.part download in progress); exporting a theme with large embedded assets blows past 32 MiB; a symlinked path in a shared state dir.","solutions":["Verify the path points to a real regular file: check fs::metadata(path).is_file() and len() <= 32*1024*1024 before importing.","Re-export or re-zip the theme so it is under 32 MiB (compress or drop large preview assets).","Ensure the download/export fully completed (no 0-byte or partial files).","Resolve symlinks to their target file before passing the path."],"exampleFix":"// before\nimport_theme_package(state_dir, &maybe_symlink_path)?;\n// after\nlet md = std::fs::metadata(&path)?;\nif md.is_file() && md.len() > 0 && md.len() <= 32 * 1024 * 1024 {\n    import_theme_package(state_dir, &path)?;\n}","handlingStrategy":"validation","validationCode":"// Rust\nlet md = std::fs::metadata(&path)?;\nlet ok = md.is_file() && md.len() > 0 && md.len() <= 32 * 1024 * 1024;","typeGuard":null,"tryCatchPattern":"// Rust\nmatch import_theme_package(state_dir, &path) {\n    Ok(t) => t,\n    Err(e) if e.to_string().contains(\"32 MiB\") => eprintln!(\"请选择一个 32 MiB 以内的 ZIP 文件\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Validate file size and type in the file picker before handing the path to the library","Complete downloads fully (check .part files are renamed)","Keep theme exports under 32 MiB by compressing preview assets","Resolve symlinks before passing paths"],"tags":["validation","file-size-limit","zip"],"backgroundTag":"payload-too-large","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}