tonhowtf/omniget · error

não foi possível abrir o zip

Error message

não foi possível abrir o zip: {}

What it means

The path was a .zip but zip::ZipArchive::new failed, so the archive cannot be opened or indexed. The underlying zip error is embedded in the message (e.g. invalid archive, unsupported compression, I/O error).

Solutions

  1. Read the embedded {} detail to identify the specific zip error
  2. Re-download the GDPR export from Reddit and verify the file size/checksum
  3. Open the zip with `unzip -t file.zip` to confirm integrity
  4. Ensure the file is not 0 bytes or an HTML page (`file export.zip`)

Example fix

// before
path: "export.zip"  // 0-byte truncated download
// after
# re-download, verify, then
path: "export.zip"  # valid, unzip -t passes
Defensive patterns

Strategy: validation

Validate before calling

fn zip_is_valid(path: &str) -> bool {
    std::fs::File::open(path)
        .map(|f| zip::ZipArchive::new(f).is_ok())
        .unwrap_or(false)
}
// assert!(zip_is_valid("export.zip"), "corrupt or truncated zip");

Try / catch

match run(opts).await {
    Err(e) if e.to_string().starts_with("não foi possível abrir o zip") => {
        // surface the embedded zip error; prompt user to re-download the export
    }
    other => other?,
}

Prevention

When it happens

Trigger: File::open succeeded but the bytes are not a valid zip: truncated/corrupt download, HTML error page saved as .zip, unsupported zip variant, or empty file.

Common situations: Interrupted download of the export; browser saved a login/error page with a .zip name; disk full or antivirus quarantining content; wrong file renamed to .zip.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/reddit/gdpr.rs:262

                }
            }
        }
        if out.is_empty() {
            return Err(anyhow!(
                "nenhum .csv nesta pasta — aponte para a pasta do export ou para o zip"
            ));
        }
        return Ok(out);
    }
    let lower = path.to_string_lossy().to_ascii_lowercase();
    if !lower.ends_with(".zip") {
        return Err(anyhow!(
            "escolha o zip do export do Reddit ou a pasta onde ele foi descompactado"
        ));
    }
    let file = std::fs::File::open(path)?;
    let mut zip =
        zip::ZipArchive::new(file).map_err(|e| anyhow!("não foi possível abrir o zip: {}", e))?;
    for i in 0..zip.len() {
        let mut entry = match zip.by_index(i) {
            Ok(e) => e,
            Err(_) => continue,
        };
        if !entry.is_file() || !is_csv(entry.name()) {
            continue;
        }
        let name = short_name(entry.name());
        let mut buf = Vec::new();
        if entry.read_to_end(&mut buf).is_ok() {
            out.insert(name, String::from_utf8_lossy(&buf).to_string());
        }
    }
    if out.is_empty() {
        return Err(anyhow!("este zip não tem nenhum .csv do export do Reddit"));
    }
    Ok(out)

View on GitHub (pinned to 8600b91f42)