tonhowtf/omniget · error

não li o backup

Error message

não li o backup {}: {}

What it means

Restore failure in hosts_block restore: the backup file chosen for restoration could not be read (missing, unreadable, or I/O error), so the previous hosts content cannot be recovered and the restore is refused rather than leaving an empty hosts file.

Solutions

  1. Verify the backup path exists and the app can read it
  2. Restore from an alternative backup if available
  3. Re-run the block operation to generate a fresh backup before restoring
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src-tauri/omniget-core/src/core/tools/hosts_block.rs:724 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/hosts_block.rs:724

    pub restored_from: Option<String>,
    pub blocked_before: usize,
    pub bytes: u64,
    pub backup: Option<String>,
    pub needs_admin: bool,
    pub staged: Option<String>,
    pub hint: Option<String>,
    pub error: Option<String>,
}

pub fn restore(opts: &RestoreOptions) -> anyhow::Result<RestoreResult> {
    let path = resolve_path(&opts.path);
    let current = std::fs::read_to_string(&path).unwrap_or_default();
    let blocked_before = count_blocked(&current);

    let (next, restored_from) = match opts.backup.as_ref().filter(|s| !s.trim().is_empty()) {
        Some(b) => {
            let text = std::fs::read_to_string(b.trim())
                .map_err(|e| anyhow!("não li o backup {}: {}", b.trim(), e))?;
            (text, Some(b.trim().to_string()))
        }
        None => (remove_from_text(&current), None),
    };

    let mut result = RestoreResult {
        path: path.to_string_lossy().to_string(),
        dry_run: opts.dry_run,
        written: false,
        removed_block: restored_from.is_none() && has_block(&current),
        restored_from,
        blocked_before,
        bytes: next.len() as u64,
        backup: None,
        needs_admin: false,
        staged: None,
        hint: None,
        error: None,

View on GitHub (pinned to 8600b91f42)