tonhowtf/omniget · error · anyhow::Error

escolha a pasta de destino

Error message

escolha a pasta de destino

What it means

tiktok::download::run validates opts.dest before doing any work; if the destination folder string is empty or whitespace it throws "escolha a pasta de destino" (choose the destination folder). It is a required-argument guard executed before create_dir_all.

Solutions

  1. Set opts.dest to a valid existing/writable directory path before calling run
  2. In UI code, disable the download action until a destination is selected
  3. Validate dest non-empty and writable at the caller boundary

Example fix

// before
let opts = Options { dest: "".into(), .. };
run(&opts).await?;
// after
let opts = Options { dest: "/home/user/Downloads/tiktok".into(), .. };
std::fs::create_dir_all(&opts.dest)?;
run(&opts).await?;
Defensive patterns

Strategy: validation

Validate before calling

if opts.dest.trim().is_empty() { return Err("destination folder required"); }
let dest = std::path::Path::new(opts.dest.trim());
std::fs::create_dir_all(dest)?;

Try / catch

match run(&opts, progress).await {
    Err(e) if e.to_string().contains("escolha a pasta de destino") => {
        // prompt user to pick a folder, then retry
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling run with Options.dest = "" or containing only whitespace — omitted field in the UI/CLI, default struct not filled, or the frontend sending an empty string.

Common situations: User hasn't picked a download folder yet; a settings reset cleared the saved destination; a binding bug where the folder picker result never reaches opts.dest.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/tiktok/download.rs:145

        _ => return Err(anyhow!("isso é um vídeo, não um perfil: {}", input)),
    }
    let url = canonical_url(&target);
    let v = super::ytdlp_json(&super::ytdlp_list_args(&url, limit, cookies)).await?;
    let entries = super::favorites::entries_from_list(&v);
    Ok(entries.into_iter().map(|e| e.url).collect())
}

fn cookies_path(opts: &Options, session: &TempCookies) -> Option<PathBuf> {
    if let Some(c) = opts.cookies.as_deref().filter(|c| !c.trim().is_empty()) {
        return Some(PathBuf::from(c));
    }
    session.path().map(|p| p.to_path_buf())
}

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

    let session = TempCookies::new(opts.session_netscape.as_deref());
    let used_session = session.is_some();
    let cookies = cookies_path(opts, &session);

    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 = queue_from_text(&opts.urls, &list_text, 0);

    if let Some(profile) = opts.profile.as_deref().filter(|p| !p.trim().is_empty()) {
        report(
            &progress,
            ID,

View on GitHub (pinned to 8600b91f42)