{"record":{"id":"e6e6aab5cc440f01","repo":"tonhowtf/omniget","slug":"n-o-gravei-pdf-write","errorCode":null,"errorMessage":"não gravei: {}","messagePattern":"não gravei: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf_write.rs","lineNumber":188,"sourceCode":"        doc.encrypt(&state)\n            .map_err(|e| anyhow!(\"não cifrei: {}\", e))?;\n        note = if opts.user_password.is_empty() {\n            \"permissões travadas (abre sem senha)\".into()\n        } else {\n            \"AES-128, senha para abrir\".into()\n        };\n    }\n    let out = out_path(\n        input,\n        &opts.output_dir,\n        &opts.suffix,\n        if opts.mode == \"remove\" {\n            \"-sem-senha\"\n        } else {\n            \"-protegido\"\n        },\n    )?;\n    doc.save(&out).map_err(|e| anyhow!(\"não gravei: {}\", e))?;\n    Ok(WriteItem {\n        input: input.to_string(),\n        output: Some(out.to_string_lossy().to_string()),\n        pages,\n        note,\n        ok: true,\n        error: None,\n    })\n}\n\npub fn password(opts: &PasswordOptions, progress: &super::ProgressFn) -> WriteResult {\n    run_each(&opts.inputs, \"pdf-password\", progress, |input| {\n        password_one(opts, input)\n    })\n}\n\n// ── Marca d'água e numeração ───────────────────────────────────────────\n","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf_write.rs#L170-L206","documentation":"Save failure in password_one(), the per-file password protection step: after applying encryption/permission state and computing the output path (with the -sem-senha or -protegido suffix), doc.save(&out) is attempted; any pdf save error is remapped to this message with the underlying error in {}. It fires when writing the processed PDF to disk fails — e.g. unwritable output directory, path conflict, or a document-level save error.","triggerScenarios":"The computed output path (input stem + '-sem-senha' or '-protegido' suffix) is unwritable: directory missing, no write permission, disk full, or path too long.","commonSituations":"Read-only output directory; input filename already extremely long so the suffixed path exceeds filesystem limits; target name collides with a directory; antivirus locks the file.","solutions":["Check the output directory exists and is writable before saving","Shorten the input filename or save to a shorter explicit output path","Check free disk space and that no other process holds the target file open","Handle the wrapped std::io error shown after 'não gravei:' for the specific OS reason"],"exampleFix":"// before\ndoc.save(&out).map_err(|e| anyhow!(\"não gravei: {}\", e))?;\n// after\nif let Some(dir) = out.parent() { std::fs::create_dir_all(dir)?; }\ndoc.save(&out).map_err(|e| anyhow!(\"não gravei {} ({}): {}\", out.display(), std::io::Error::last_os_error(), e))?;","handlingStrategy":"try-catch","validationCode":"let out_dir = out.parent().unwrap_or(std::path::Path::new(\".\"));\nif !out_dir.exists() { std::fs::create_dir_all(out_dir)?; }\nlet test = out_dir.join(\".write_test\");\nstd::fs::File::create(&test)?; std::fs::remove_file(&test)?;","typeGuard":null,"tryCatchPattern":"if let Err(e) = doc.save(&out) {\n    eprintln!(\"falha ao gravar {}: {}\", out.display(), e);\n    return Err(e.into());\n}","preventionTips":["Create output directories and check writability before saving","Cap suffixed output names to filesystem length limits","Check free disk space for batch operations"],"tags":["pdf","file-write","io"],"backgroundTag":"file-write-failed","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"}