tonhowtf/omniget · error · anyhow::Error

arquivo não existe

Error message

arquivo não existe

What it means

`convert_one` in sticker.rs validates that the sticker source file exists before doing any conversion work. If `Path::new(input).exists()` is false — the file is missing, deleted, renamed, or the path is wrong — it throws "arquivo não existe". This is the first guard in the sticker conversion pipeline (`run` -> `convert_one`).

Solutions

  1. Check `std::path::Path::new(input).exists()` (or `std::fs::metadata(input).is_ok()`) before invoking conversion and surface a user-facing message with the resolved absolute path.
  2. Resolve relative input paths to absolute paths (std::fs::canonicalize) against the intended base directory before calling the API.
  3. Verify the file still exists right before conversion in batch workflows; re-enumerate the file list instead of using a stale one.
  4. Ensure a local filesystem path is passed, not a URL or resource identifier — download/copy remote sources to disk first.

Example fix

// before
convert_one(&opts, user_input, progress).await?;

// after
let p = std::path::Path::new(&user_input);
if !p.exists() {
    return Err(anyhow!("arquivo de origem nao encontrado: {}", p.display()));
}
convert_one(&opts, &user_input, progress).await?;
Defensive patterns

Strategy: validation

Validate before calling

let p = std::path::Path::new(input);
if !p.is_file() {
    return Err(anyhow!("entrada invalida/nao encontrada: {}", p.display()));
}

Type guard

fn is_existing_file(p: &str) -> bool {
    std::fs::metadata(p).map(|m| m.is_file()).unwrap_or(false)
}

Try / catch

match convert_one(&opts, input, progress).await {
    Err(e) if e.to_string().contains("arquivo n\u00e3o existe") => {
        eprintln!("verifique o caminho: {}", input);
    }
    r => { r?; }
}

Prevention

When it happens

Trigger: Calling the sticker conversion (`run`/`convert_one`) with `input` pointing to a nonexistent file: wrong relative path (wrong CWD), file deleted or renamed after listing, path with a typo, or a URL/remote path passed where only a local filesystem path is accepted.

Common situations: Users dragging in files from temp folders that were cleaned up; batch jobs whose input list was generated before files were moved; running the app from a different working directory so relative paths break; confusing sticker IDs with file paths.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/45c521fb3a4755b6. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/sticker.rs:423

    }
}

async fn source_seconds(input: &Path) -> f64 {
    crate::core::ffmpeg::probe(input)
        .await
        .map(|p| p.duration_seconds)
        .unwrap_or(0.0)
}

async fn convert_one(
    ffmpeg: &Path,
    opts: &StickerOptions,
    input: &str,
    progress: &super::ProgressFn,
) -> anyhow::Result<StickerItem> {
    let inp = Path::new(input);
    if !inp.exists() {
        return Err(anyhow!("arquivo não existe"));
    }
    let animated = wants_animated(opts, input);
    let mut spec = spec(&opts.target, animated);
    if opts.max_kb > 0 {
        spec.max_bytes = opts.max_kb * 1024;
    }

    let mut duration = opts.duration;
    if animated {
        let real = source_seconds(inp).await;
        let sobra = (real - opts.start).max(0.0);
        if sobra > 0.0 {
            duration = if duration > 0.0 {
                duration.min(sobra)
            } else {
                sobra
            };
        }

View on GitHub (pinned to 8600b91f42)