BigPizzaV3/CodexPlusPlus · warning

主题市场缓存超过大小限制

Error message

主题市场缓存超过大小限制

What it means

`read_cached_manifest` loads the locally cached theme-market index from the state directory. Before parsing, it checks the file's size on disk against `MARKET_INDEX_LIMIT` and refuses to read a cache that exceeds it, guarding against memory blowups and poisoned/corrupted cache files. Callers of `load_market` typically fall back to fetching a fresh manifest from the network when the cache read fails.

Solutions

  1. Delete the oversized cache file in the state directory so `load_market` re-fetches a fresh, valid manifest from the network.
  2. Check what wrote the file: if a backup/restore or sync tool replaced it, restore the correct cache or let it regenerate.
  3. If your market legitimately serves an index larger than `MARKET_INDEX_LIMIT`, raise that constant in `dream_skin_market.rs`.
  4. Verify the manifest JSON itself is valid and reasonably sized (`wc -c` on the cache file) before re-caching it.
Defensive patterns

Strategy: fallback

Validate before calling

let path = state_dir.join(MARKET_CACHE_FILE);
if let Ok(meta) = std::fs::metadata(&path) {
    if meta.len() > MARKET_INDEX_LIMIT as u64 {
        let _ = std::fs::remove_file(&path); // let load_market refetch
    }
}

Try / catch

match load_market(state_dir).await {
    Err(e) if e.to_string().contains("缓存超过大小限制") => {
        let _ = std::fs::remove_file(state_dir.join(MARKET_CACHE_FILE));
        let fresh = load_market(state_dir).await?; // refetch from network
    }
    other => other?,
}

Prevention

When it happens

Trigger: `load_market` invokes `read_cached_manifest` and the cache file (state_dir + market cache path) has `metadata.len()` greater than `MARKET_INDEX_LIMIT` bytes — e.g. the cache was written by another tool, corrupted, or the manifest genuinely grew past the cap.

Common situations: State directory manually edited or restored from a backup containing a huge file; disk corruption; a forked/modified version of the app writing unlimited manifests; syncing the state dir across machines where an unrelated file took the cache filename's place.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


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

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin_market.rs:294

        bytes.extend_from_slice(&chunk);
    }
    if bytes.is_empty() {
        bail!("下载内容为空");
    }
    Ok(bytes)
}

fn cache_manifest(state_dir: &Path, manifest: &DreamSkinMarketManifest) -> anyhow::Result<()> {
    let bytes = serde_json::to_vec_pretty(manifest)?;
    crate::settings::atomic_write(&state_dir.join(MARKET_CACHE_FILE), &bytes)
}

fn read_cached_manifest(state_dir: &Path) -> anyhow::Result<DreamSkinMarketManifest> {
    let path = state_dir.join(MARKET_CACHE_FILE);
    let metadata = std::fs::metadata(&path)
        .with_context(|| format!("主题市场缓存不存在:{}", path.display()))?;
    if metadata.len() > MARKET_INDEX_LIMIT as u64 {
        bail!("主题市场缓存超过大小限制");
    }
    let mut manifest: DreamSkinMarketManifest =
        serde_json::from_slice(&std::fs::read(&path)?).context("主题市场缓存不是有效 JSON")?;
    validate_manifest(&mut manifest)?;
    Ok(manifest)
}

fn read_install_records(state_dir: &Path) -> anyhow::Result<MarketInstallRecords> {
    let path = state_dir.join(MARKET_INSTALLS_FILE);
    if !path.is_file() {
        return Ok(MarketInstallRecords {
            schema_version: market_schema_version(),
            themes: BTreeMap::new(),
        });
    }
    let records: MarketInstallRecords = serde_json::from_slice(&std::fs::read(path)?)?;
    if records.schema_version != market_schema_version() {
        bail!("不支持的主题市场安装记录版本");

View on GitHub (pinned to b1ed92e5e4)