tonhowtf/omniget · error

não consegui ler

Error message

não consegui ler {}

What it means

This is a with_context-wrapped io::Error from std::fs::read when the tool could not read the user-supplied Letterboxd ZIP file at opts.zip_path. The context message interpolates the offending path, so 'não consegui ler <path>' identifies exactly which file failed to open.

Solutions

  1. Verify the path exists with fs::metadata before calling run and fix any typo.
  2. Re-download the ZIP from letterboxd.com/settings/data/ and pass the new path.
  3. Check file permissions and, on macOS, ensure the app has Files/Folder access.
  4. Alternatively drop the zip_path and provide Letterboxd session cookies so the tool downloads the export itself.

Example fix

// before
let opts = Options { zip_path: Some("~/Downloads/export.zip".into()), .. }; // ~ not expanded
run(&opts, p).await?;
// after
let expanded = shellexpand::tilde("~/Downloads/export.zip").to_string();
assert!(std::path::Path::new(&expanded).is_file(), "zip not found: {expanded}");
let opts = Options { zip_path: Some(expanded), .. };
run(&opts, p).await?;
Defensive patterns

Strategy: validation

Validate before calling

if let Some(zip) = opts.zip_path.as_deref().map(str::trim) {
    let meta = std::fs::metadata(zip)
        .with_context(|| format!("não consegui ler {zip}"))?;
    anyhow::ensure!(meta.is_file(), "{zip} não é um arquivo");
}

Type guard

fn zip_readable(zip_path: &str) -> bool {
    std::path::Path::new(zip_path.trim()).is_file()
}

Try / catch

match letterboxd::run(&opts, &p).await {
    Err(e) if e.to_string().starts_with("não consegui ler") => {
        eprintln!("verifique o caminho do ZIP: {e}");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling run with opts.zip_path pointing to a file that doesn't exist, was moved/deleted, or lacks read permission; std::fs::read(path) returns Err and it is propagated via the ? operator in run().

Common situations: Typo in the ZIP path; file downloaded to Downloads folder but a different path given; ZIP deleted between selection and run; permission restrictions (sandboxed app can't read user-chosen path).

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 tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/260b1940045c3129. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/lists/letterboxd.rs:372

    let dest = PathBuf::from(opts.dest.trim());
    if opts.dest.trim().is_empty() {
        return Err(anyhow!("escolha a pasta de destino"));
    }
    std::fs::create_dir_all(&dest)?;
    let f = Fetcher::new(opts.delay_ms, opts.session_netscape.as_deref(), DOMAIN)?;

    // 1. O ZIP: local ou baixado com a sessão.
    let (bytes, source) = match opts.zip_path.as_deref().map(str::trim) {
        Some(path) if !path.is_empty() => {
            report(&p, TOOL_ID, "progress", 0, Some(3), Some(path.to_string()));
            (
                std::fs::read(path).with_context(|| format!("não consegui ler {}", path))?,
                path.to_string(),
            )
        }
        _ => {
            if !f.has_session() {
                return Err(anyhow!(
                    "sem sessão do Letterboxd: capture os cookies de letterboxd.com na extensão, ou aponte um ZIP já baixado de letterboxd.com/settings/data/"
                ));
            }
            report(
                &p,
                TOOL_ID,
                "progress",
                0,
                Some(3),
                Some(EXPORT_URL.to_string()),
            );
            let (b, ctype) = f.get_bytes(EXPORT_URL).await?;
            if ctype.contains("text/html") || b.len() < 200 {
                let body = String::from_utf8_lossy(&b);
                if is_cloudflare_wall(&body) {
                    return Err(anyhow!(
                        "o Cloudflare do Letterboxd barrou o download. Abra letterboxd.com no navegador, passe pelo \"Just a moment\" e capture os cookies de novo na extensão — o cf_clearance precisa vir junto"
                    ));

View on GitHub (pinned to 8600b91f42)