{"record":{"id":"eea5922db08810d6","repo":"BigPizzaV3/CodexPlusPlus","slug":"normalized","errorCode":null,"errorMessage":"主题包包含重复文件：{normalized}","messagePattern":"主题包包含重复文件：(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":875,"sourceCode":"                name.split_once('/').is_none_or(|(candidate, file)| {\n                    candidate != prefix || file.is_empty() || file.contains('/')\n                })\n            })\n        {\n            bail!(\"主题包只能包含唯一一层主题目录\");\n        }\n        Some(format!(\"{prefix}/\"))\n    };\n\n    let mut files = std::collections::BTreeMap::new();\n    for (name, content) in content_entries {\n        let normalized = prefix\n            .as_deref()\n            .and_then(|prefix| name.strip_prefix(prefix))\n            .unwrap_or(&name)\n            .to_string();\n        if files.insert(normalized.clone(), content).is_some() {\n            bail!(\"主题包包含重复文件：{normalized}\");\n        }\n    }\n    Ok(files)\n}\n\nfn validate_image_content(name: &str, bytes: &[u8]) -> anyhow::Result<()> {\n    let valid = match name {\n        \"background.png\" => bytes.starts_with(&[0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a]),\n        \"background.jpg\" => bytes.starts_with(&[0xff, 0xd8, 0xff]),\n        \"background.webp\" => {\n            bytes.len() >= 12 && &bytes[..4] == b\"RIFF\" && &bytes[8..12] == b\"WEBP\"\n        }\n        _ => false,\n    };\n    if !valid {\n        bail!(\"主题包背景图片内容与扩展名不一致：{name}\");\n    }\n    Ok(())","sourceCodeStart":857,"sourceCodeEnd":893,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L857-L893","documentation":"After stripping the optional theme-directory prefix, normalize_package_entries inserts each normalized file name into a BTreeMap; if the same normalized name already exists it bails with this message. This prevents ambiguous duplicate files (e.g. same file at root and inside the theme dir would normalize to the same key).","triggerScenarios":"validate_and_read_package processes an archive containing two entries that normalize to the same name, e.g. 'a.css' and 'theme/a.css' when prefix is 'theme/', or literally duplicated entry names in the zip.","commonSituations":"Appending files to an existing archive without removing the old copy; zips that store the same path twice; a packaging script that copies files into both root and theme dir.","solutions":["Remove the duplicate entry from the archive and repack.","Make your packager de-duplicate by normalized name before writing entries.","Ensure files exist in exactly one place (root or theme dir), not both."],"exampleFix":"# before archive entries: a.css, theme/a.css\n# after: theme/a.css only","handlingStrategy":"validation","validationCode":"fn no_duplicates(entries: &[String]) -> bool {\n    let mut seen = std::collections::HashSet::new();\n    entries.iter().all(|n| seen.insert(n.clone()))\n}","typeGuard":null,"tryCatchPattern":"match validate_and_read_package(path, platform) {\n    Ok(pkg) => install(pkg),\n    Err(e) if e.to_string().contains(\"重复文件\") => eprintln!(\"remove duplicate entries and repack\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Build archives from a fresh temp dir instead of appending.","De-duplicate by normalized name in the packager.","Inspect zip listings in CI."],"tags":["zip","validation","duplicate-file"],"backgroundTag":"file-already-exists","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"}