{"record":{"id":"6cafbf1753ee3500","repo":"tonhowtf/omniget","slug":"n-o-achei-a-pasta-de-dados-do-app","errorCode":null,"errorMessage":"não achei a pasta de dados do app","messagePattern":"não achei a pasta de dados do app","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/sponsorblock.rs","lineNumber":169,"sourceCode":"pub fn generate_private_id() -> String {\n    format!(\n        \"{}{}\",\n        uuid::Uuid::new_v4().simple(),\n        uuid::Uuid::new_v4().simple()\n    )\n}\n\n/// SHA-256 da chave privada, só para a UI mostrar um identificador estável\n/// sem exibir a chave. O identificador público de verdade é derivado pelo\n/// servidor do SponsorBlock, não por aqui.\npub fn public_fingerprint(private: &str) -> String {\n    let mut h = Sha256::new();\n    h.update(private.as_bytes());\n    hex::encode(h.finalize())\n}\n\nfn user_file() -> anyhow::Result<std::path::PathBuf> {\n    let dir = super::tools_dir().ok_or_else(|| anyhow!(\"não achei a pasta de dados do app\"))?;\n    std::fs::create_dir_all(&dir)?;\n    Ok(dir.join(USER_FILE))\n}\n\n/// A chave privada da máquina, criada na primeira vez e reusada depois.\npub fn local_user_id() -> anyhow::Result<String> {\n    let path = user_file()?;\n    if let Ok(existing) = std::fs::read_to_string(&path) {\n        let existing = existing.trim().to_string();\n        if existing.len() >= 30 {\n            return Ok(existing);\n        }\n    }\n    let fresh = generate_private_id();\n    std::fs::write(&path, fresh.as_bytes())?;\n    Ok(fresh)\n}\n","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/sponsorblock.rs#L151-L187","documentation":"Thrown by `user_file` when `super::tools_dir()` returns None, meaning the library cannot locate the application data directory on this machine. `local_user_id` depends on it to store/read the machine's private key, so SponsorBlock user identification cannot proceed.","triggerScenarios":"Calling `local_user_id()` (or anything that reaches `user_file()`) on a system where the app data dir cannot be resolved — e.g. unset HOME/XDG dirs on Linux, nonstandard packaging sandbox, or the Tauri context not providing a data path.","commonSituations":"Running the binary headless or in CI without HOME set; Flatpak/Snap sandbox restricting data dirs; running on an OS the tools_dir resolver does not handle; launching outside the normal Tauri app environment.","solutions":["Ensure the app runs in an environment where the OS data directory is resolvable (HOME set on Linux/macOS, APPDATA on Windows).","Launch through the normal Tauri app entry point so the data-dir context is available instead of calling the core lib standalone.","Set XDG_DATA_HOME/XDG_CONFIG_HOME explicitly in sandboxed or CI environments.","Fix/extend `tools_dir()` to cover the platform or container layout in question."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure a data dir is available before running\nif std::env::var_os(\"HOME\").is_none() && cfg!(target_os = \"linux\") {\n    return Err(\"HOME not set; app data dir unresolvable\".into());\n}","typeGuard":null,"tryCatchPattern":"match sponsorblock::local_user_id() {\n    Ok(id) => use(id),\n    Err(e) if e.to_string().contains(\"pasta de dados\") => {\n        eprintln!(\"run inside the app environment or set XDG_DATA_HOME\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Launch via the normal Tauri app entry point.","Set HOME/XDG dirs in CI, containers, and sandboxes.","Don't run the core lib headless without an OS data directory."],"tags":["config","filesystem","environment","sponsorblock"],"backgroundTag":"missing-config-value","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"}