BigPizzaV3/CodexPlusPlus · error

主题包包含重复文件:

Error message

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

What it means

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).

Solutions

  1. Remove the duplicate entry from the archive and repack.
  2. Make your packager de-duplicate by normalized name before writing entries.
  3. Ensure files exist in exactly one place (root or theme dir), not both.

Example fix

# before archive entries: a.css, theme/a.css
# after: theme/a.css only
Defensive patterns

Strategy: validation

Validate before calling

fn no_duplicates(entries: &[String]) -> bool {
    let mut seen = std::collections::HashSet::new();
    entries.iter().all(|n| seen.insert(n.clone()))
}

Try / catch

match validate_and_read_package(path, platform) {
    Ok(pkg) => install(pkg),
    Err(e) if e.to_string().contains("重复文件") => eprintln!("remove duplicate entries and repack"),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


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

Appendix: 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 b1ed92e5e4)