BigPizzaV3/CodexPlusPlus · warning

DreamSkin 社区缓存无效

Error message

DreamSkin 社区缓存无效

What it means

read_cached_catalog validates the on-disk community catalog cache file before parsing: it must be a regular, non-symlink file no larger than CATALOG_BYTES_LIMIT. If the cache fails these checks (or symlink_metadata itself fails, or the JSON is invalid further down), the cache is considered unusable and the loader falls back to a network fetch.

Solutions

  1. Delete the invalid cache file and let load_community_catalog refetch the catalog from the network.
  2. Check the state_dir for symlink or sync-tool interference and use a plain directory.
  3. Ensure no concurrent writer truncates/oversizes the cache; write atomically (temp file + rename).

Example fix

// before
let catalog = load_community_catalog(state_dir, false)?; // force-cache read errors surface
// after
let catalog = load_community_catalog(state_dir, true)?; // force refresh, ignore/rebuild cache
Defensive patterns

Strategy: fallback

Validate before calling

// Rust
let md = std::fs::symlink_metadata(&cache_path);
let cache_ok = md.as_ref().map(|m| m.is_file() && m.len() <= CATALOG_LIMIT).unwrap_or(false);

Try / catch

// Rust
let catalog = match load_community_catalog(state_dir, false).await {
    Ok(c) => c,
    Err(_) => load_community_catalog(state_dir, true).await?, // force network refresh, rebuilding cache
};

Prevention

When it happens

Trigger: Calling load_community_catalog when the CACHE_FILE in state_dir is a symlink, a directory/special file, or larger than the catalog byte limit; or when symlink_metadata errors (missing path propagates a different error).

Common situations: State dir shared via symlinked folders; a corrupted/huge cache from a bad previous write; antivirus or sync tools replacing the file; an attacker-planted symlink.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin_community.rs:398

    }
}

fn cache_catalog(state_dir: &Path, catalog: &DreamSkinCommunityCatalog) -> anyhow::Result<()> {
    let path = state_dir.join(CACHE_FILE);
    if let Some(parent) = path.parent() {
        std::fs::create_dir_all(parent)?;
    }
    crate::settings::atomic_write(&path, &serde_json::to_vec(catalog)?)
}

fn read_cached_catalog(state_dir: &Path) -> anyhow::Result<DreamSkinCommunityCatalog> {
    let path = state_dir.join(CACHE_FILE);
    let metadata = std::fs::symlink_metadata(&path)?;
    if !metadata.file_type().is_file()
        || metadata.file_type().is_symlink()
        || metadata.len() as usize > CATALOG_BYTES_LIMIT
    {
        bail!("DreamSkin 社区缓存无效");
    }
    let mut catalog: DreamSkinCommunityCatalog = serde_json::from_slice(&std::fs::read(path)?)?;
    let (items, skipped) = normalize_and_filter_catalog(catalog.items);
    catalog.items = items;
    catalog.total = catalog.items.len();
    if skipped > 0 {
        append_warning(
            &mut catalog.warning,
            format!("已跳过 {skipped} 个元数据无效的 DreamSkin 社区缓存主题。"),
        );
    }
    Ok(catalog)
}

fn append_warning(warning: &mut String, message: String) {
    if !warning.is_empty() {
        warning.push(' ');
    }

View on GitHub (pinned to b1ed92e5e4)