BigPizzaV3/CodexPlusPlus · error

主题包包含重复文件:{normalized}

Error message

主题包包含重复文件:{normalized}

What it means

Deduplication guard in normalize_package_entries: after stripping the common theme-directory prefix, two entries normalize to the same file name (BTreeMap insert returned a previous value). Duplicate normalized files would silently overwrite each other, so the package is rejected.

Source

Thrown at crates/codex-plus-core/src/dream_skin_package.rs:875

                name.split_once('/').is_none_or(|(candidate, file)| {
                    candidate != prefix || file.is_empty() || file.contains('/')
                })
            })
        {
            bail!("主题包只能包含唯一一层主题目录");
        }
        Some(format!("{prefix}/"))
    };

    let mut files = std::collections::BTreeMap::new();
    for (name, content) in content_entries {
        let normalized = prefix
            .as_deref()
            .and_then(|prefix| name.strip_prefix(prefix))
            .unwrap_or(&name)
            .to_string();
        if files.insert(normalized.clone(), content).is_some() {
            bail!("主题包包含重复文件:{normalized}");
        }
    }
    Ok(files)
}

fn validate_image_content(name: &str, bytes: &[u8]) -> anyhow::Result<()> {
    let valid = match name {
        "background.png" => bytes.starts_with(&[0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a]),
        "background.jpg" => bytes.starts_with(&[0xff, 0xd8, 0xff]),
        "background.webp" => {
            bytes.len() >= 12 && &bytes[..4] == b"RIFF" && &bytes[8..12] == b"WEBP"
        }
        _ => false,
    };
    if !valid {
        bail!("主题包背景图片内容与扩展名不一致:{name}");
    }
    Ok(())

View on GitHub (pinned to f2074595a2)

Solutions

  1. Remove duplicate files from the ZIP
  2. Ensure each required file appears exactly once after prefix stripping
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-core/src/dream_skin_package.rs:875 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23). Data as JSON: /api/errors/eea5922db08810d6. Report an issue: GitHub.