tonhowtf/omniget · error

não gravei: {}

Error message

não gravei: {}

What it means

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.

Solutions

  1. Check the output directory exists and is writable before saving
  2. Shorten the input filename or save to a shorter explicit output path
  3. Check free disk space and that no other process holds the target file open
  4. Handle the wrapped std::io error shown after 'não gravei:' for the specific OS reason

Example fix

// before
doc.save(&out).map_err(|e| anyhow!("não gravei: {}", e))?;
// after
if let Some(dir) = out.parent() { std::fs::create_dir_all(dir)?; }
doc.save(&out).map_err(|e| anyhow!("não gravei {} ({}): {}", out.display(), std::io::Error::last_os_error(), e))?;
Defensive patterns

Strategy: try-catch

Validate before calling

let out_dir = out.parent().unwrap_or(std::path::Path::new("."));
if !out_dir.exists() { std::fs::create_dir_all(out_dir)?; }
let test = out_dir.join(".write_test");
std::fs::File::create(&test)?; std::fs::remove_file(&test)?;

Try / catch

if let Err(e) = doc.save(&out) {
    eprintln!("falha ao gravar {}: {}", out.display(), e);
    return Err(e.into());
}

Prevention

When it happens

Trigger: The computed output path (input stem + '-sem-senha' or '-protegido' suffix) is unwritable: directory missing, no write permission, disk full, or path too long.

Common situations: 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.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/pdf_write.rs:188

        doc.encrypt(&state)
            .map_err(|e| anyhow!("não cifrei: {}", e))?;
        note = if opts.user_password.is_empty() {
            "permissões travadas (abre sem senha)".into()
        } else {
            "AES-128, senha para abrir".into()
        };
    }
    let out = out_path(
        input,
        &opts.output_dir,
        &opts.suffix,
        if opts.mode == "remove" {
            "-sem-senha"
        } else {
            "-protegido"
        },
    )?;
    doc.save(&out).map_err(|e| anyhow!("não gravei: {}", e))?;
    Ok(WriteItem {
        input: input.to_string(),
        output: Some(out.to_string_lossy().to_string()),
        pages,
        note,
        ok: true,
        error: None,
    })
}

pub fn password(opts: &PasswordOptions, progress: &super::ProgressFn) -> WriteResult {
    run_each(&opts.inputs, "pdf-password", progress, |input| {
        password_one(opts, input)
    })
}

// ── Marca d'água e numeração ───────────────────────────────────────────

View on GitHub (pinned to 8600b91f42)