{"record":{"id":"115ee60c2f8664be","repo":"tonhowtf/omniget","slug":"escolha-a-pasta-de-destino-download","errorCode":null,"errorMessage":"escolha a pasta de destino","messagePattern":"escolha a pasta de destino","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/tiktok/download.rs","lineNumber":145,"sourceCode":"        _ => return Err(anyhow!(\"isso é um vídeo, não um perfil: {}\", input)),\n    }\n    let url = canonical_url(&target);\n    let v = super::ytdlp_json(&super::ytdlp_list_args(&url, limit, cookies)).await?;\n    let entries = super::favorites::entries_from_list(&v);\n    Ok(entries.into_iter().map(|e| e.url).collect())\n}\n\nfn cookies_path(opts: &Options, session: &TempCookies) -> Option<PathBuf> {\n    if let Some(c) = opts.cookies.as_deref().filter(|c| !c.trim().is_empty()) {\n        return Some(PathBuf::from(c));\n    }\n    session.path().map(|p| p.to_path_buf())\n}\n\npub async fn run(opts: &Options, progress: ProgressFn) -> Result<DownloadResult> {\n    let dest = PathBuf::from(&opts.dest);\n    if opts.dest.trim().is_empty() {\n        return Err(anyhow!(\"escolha a pasta de destino\"));\n    }\n    std::fs::create_dir_all(&dest)?;\n\n    let session = TempCookies::new(opts.session_netscape.as_deref());\n    let used_session = session.is_some();\n    let cookies = cookies_path(opts, &session);\n\n    let list_text = match opts.list_file.as_deref().filter(|p| !p.trim().is_empty()) {\n        Some(path) => std::fs::read_to_string(path)\n            .map_err(|e| anyhow!(\"não consegui ler a lista {}: {}\", path, e))?,\n        None => String::new(),\n    };\n    let mut queue = queue_from_text(&opts.urls, &list_text, 0);\n\n    if let Some(profile) = opts.profile.as_deref().filter(|p| !p.trim().is_empty()) {\n        report(\n            &progress,\n            ID,","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/tiktok/download.rs#L127-L163","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set opts.dest to a valid existing/writable directory path before calling run","In UI code, disable the download action until a destination is selected","Validate dest non-empty and writable at the caller boundary"],"exampleFix":"// before\nlet opts = Options { dest: \"\".into(), .. };\nrun(&opts).await?;\n// after\nlet opts = Options { dest: \"/home/user/Downloads/tiktok\".into(), .. };\nstd::fs::create_dir_all(&opts.dest)?;\nrun(&opts).await?;","handlingStrategy":"validation","validationCode":"if opts.dest.trim().is_empty() { return Err(\"destination folder required\"); }\nlet dest = std::path::Path::new(opts.dest.trim());\nstd::fs::create_dir_all(dest)?;","typeGuard":null,"tryCatchPattern":"match run(&opts, progress).await {\n    Err(e) if e.to_string().contains(\"escolha a pasta de destino\") => {\n        // prompt user to pick a folder, then retry\n    }\n    other => other,\n}","preventionTips":["Persist the last-used destination folder as default","Disable the download button until dest is set","Trim inputs at the UI boundary","Check write access to the folder before download starts"],"tags":["tiktok","missing-argument","validation","empty-input","rust"],"backgroundTag":"missing-required-argument","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}