tonhowtf/omniget · error · anyhow::Error

não consegui ler a lista

Error message

não consegui ler a lista {}: {}

What it means

When opts.list_file points to a file, sound::run reads it with std::fs::read_to_string; if that fails (missing file, permissions, invalid UTF-8) the IO error is wrapped in this message. The list file is an optional way to feed extra URLs, so the library treats an unreadable explicit path as a hard error rather than silently ignoring it.

Solutions

  1. Verify the list file exists and is readable at the exact path in opts.list_file
  2. Convert the list file to UTF-8 encoding
  3. Clear opts.list_file (empty/whitespace) if you do not actually want a list file, so the None branch is used

Example fix

// before
let opts = Options { list_file: Some("lists/som.txt".into()), ..opts };
// after
let path = "lists/som.txt";
if !path.is_empty() {
    std::fs::metadata(path).map_err(|e| anyhow!("lista ausente: {e}"))?;
}
let opts = Options { list_file: Some(path.into()), ..opts };
Defensive patterns

Strategy: validation

Validate before calling

if let Some(path) = opts.list_file.as_deref().filter(|p| !p.trim().is_empty()) {
    std::fs::metadata(path).map_err(|e| anyhow!("lista '{}' ilegível: {}", path, e))?;
}

Prevention

When it happens

Trigger: opts.list_file is set to a path that does not exist, is a directory, lacks read permission, or contains invalid UTF-8; the path is set but non-empty so the Some branch executes.

Common situations: Typo in the list file path; file deleted or moved after being configured; relative path resolved from a different working directory; file saved in an encoding that is not valid UTF-8.

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/f3c5eee4bba2e4b3. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/tiktok/sound.rs:306

pub async fn run(opts: &Options, progress: ProgressFn) -> Result<SoundResult> {
    if opts.dest.trim().is_empty() {
        return Err(anyhow!("escolha a pasta de destino"));
    }
    let dest = PathBuf::from(&opts.dest);
    std::fs::create_dir_all(&dest)?;

    let session = TempCookies::new(opts.session_netscape.as_deref());
    let used_session = session.is_some();
    let cookies: Option<PathBuf> = opts
        .cookies
        .as_deref()
        .filter(|c| !c.trim().is_empty())
        .map(PathBuf::from)
        .or_else(|| session.path().map(|p| p.to_path_buf()));

    let list_text = match opts.list_file.as_deref().filter(|p| !p.trim().is_empty()) {
        Some(path) => std::fs::read_to_string(path)
            .map_err(|e| anyhow!("não consegui ler a lista {}: {}", path, e))?,
        None => String::new(),
    };
    let mut queue = expand_inputs(&opts.urls);
    for url in expand_inputs(&list_text) {
        if !queue.contains(&url) {
            queue.push(url);
        }
    }
    if queue.is_empty() {
        return Err(anyhow!("nenhum link de vídeo do TikTok na entrada"));
    }

    let audio_format = match opts.format.as_str() {
        "m4a" => "m4a",
        "best" => "best",
        _ => "mp3",
    };
    let ffmpeg = crate::core::dependencies::find_tool("ffmpeg").await;

View on GitHub (pinned to 8600b91f42)