tonhowtf/omniget · error

escolha a pasta de saída

Error message

escolha a pasta de saída

What it means

`resolve_output_dir` in the bilibili danmaku exporter throws this when no explicit output folder was supplied and the OS-level fallbacks (`dirs::download_dir()` then `dirs::home_dir()`) both return None. It means the exporter cannot determine where to write the danmaku file, so it refuses to guess.

Solutions

  1. Pass an explicit, non-empty output directory from the caller instead of relying on the default.
  2. Ensure HOME (and XDG env vars on Linux) is set for the process running the app.
  3. On first launch, persist a user-chosen output folder in settings and always send it.
  4. As a last resort, create a known writable directory (e.g. app data dir) and pass that as output_dir.

Example fix

// before
let out = "";
export_danmaku(parts, &out).await?;
// after
let out = std::env::var("HOME").map(PathBuf::from).unwrap_or_else(|_| app_data_dir());
export_danmaku(parts, &out.to_string_lossy().as_ref()).await?;
Defensive patterns

Strategy: validation

Validate before calling

fn valid_output_dir(p: &str) -> bool {
    let t = p.trim();
    !t.is_empty() && std::path::Path::new(t).is_dir()
}

Try / catch

match export_danmaku(input, out_dir) {
    Err(e) if e.to_string().contains("pasta de saída") => prompt_user_for_folder(),
    Err(e) => return Err(e),
    Ok(v) => v,
}

Prevention

When it happens

Trigger: Calling the export path with an empty or whitespace-only output directory string while the process runs in an environment where the XDG/home lookup fails (e.g. stripped HOME/XDG env vars, embedded or containerized run with no home directory, or a misconfigured system where neither ~/Downloads nor ~ can be resolved).

Common situations: Running the Tauri app as a systemd service or in a sandboxed CI container without HOME set; running with a deleted home directory; passing an empty string from the frontend instead of a real path; Linux systems with unusual XDG_CONFIG_HOME/XDG_DOWNLOAD_DIR setups.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/src/platforms/bilibili/danmaku/export.rs:295

            if !out.contains(&f) {
                out.push(f);
            }
        }
    }
    if out.is_empty() {
        out = vec![DanmakuFormat::Xml, DanmakuFormat::Ass, DanmakuFormat::Json];
    }
    out
}

fn output_dir(raw: &str) -> Result<PathBuf> {
    let trimmed = raw.trim();
    if !trimmed.is_empty() {
        return Ok(PathBuf::from(trimmed));
    }
    dirs::download_dir()
        .or_else(dirs::home_dir)
        .ok_or_else(|| anyhow!("escolha a pasta de saída"))
}

/// `Título - P2 Nome da parte`, já sem os caracteres que o sistema recusa.
/// Vídeo de uma parte só não ganha sufixo.
fn file_stem(title: &str, part: &DanmakuPart, total_parts: usize) -> String {
    let base = sanitize_filename::sanitize(title.trim());
    let base = if base.is_empty() {
        "bilibili".to_string()
    } else {
        base
    };
    if total_parts <= 1 {
        return base;
    }
    let part_name = sanitize_filename::sanitize(&part.title);
    let tail = if part_name.is_empty() || part_name == base {
        format!("P{}", part.page)
    } else {

View on GitHub (pinned to 8600b91f42)