moonD4rk/HackBrowserData · error

write archive %s: %w

Error message

write archive %s: %w

What it means

WriteArchive wraps failures from fileutil.ZipDir(outPath, staging) — the step that compresses the staged files into the final archive — with the output path for context. The underlying %w error (I/O failure, disk full, permission problem) is preserved for errors.Is/As unwrapping. This is a wrapper error: diagnose the cause from the wrapped error.

Source

Thrown at browser/archive.go:65

			seen[entry] = true

			dst := filepath.Join(staging, key, filepath.FromSlash(src.LayoutRel))
			if err := os.MkdirAll(filepath.Dir(dst), 0o755); err != nil {
				log.Warnf("archive: %s: %v", entry, err)
				continue
			}
			if err := session.Acquire(src.AbsPath, dst, src.IsDir); err != nil {
				log.Warnf("archive: acquire %s: %v", entry, err)
				continue
			}
			count++
		}
	}
	if count == 0 {
		return 0, fmt.Errorf("no decryption-relevant files found to archive")
	}
	if err := fileutil.ZipDir(outPath, staging); err != nil {
		return 0, fmt.Errorf("write archive %s: %w", outPath, err)
	}
	return count, nil
}

View on GitHub (pinned to 0503d04d7a)

Solutions

  1. Inspect the wrapped error (%w) from the message to identify the specific I/O cause.
  2. Ensure the output directory exists and is writable: create it with os.MkdirAll before calling WriteArchive.
  3. Check free disk space and that outPath doesn't collide with an existing directory.
  4. Re-run with a different output path if the file is locked by another process/AV.

Example fix

// before: output dir may not exist
WriteArchive(profileDir, "/tmp/out/archive.zip")
// after
os.MkdirAll("/tmp/out", 0o755)
WriteArchive(profileDir, "/tmp/out/archive.zip")
Defensive patterns

Strategy: try-catch

Validate before calling

if err := os.MkdirAll(filepath.Dir(outPath), 0o755); err != nil {
    return err
}
if info, err := os.Stat(filepath.Dir(outPath)); err != nil || !info.IsDir() {
    return fmt.Errorf("output dir not writable")
}

Try / catch

n, err := browser.WriteArchive(profileDir, outPath)
var perr *fs.PathError
if err != nil {
    if errors.As(err, &perr) {
        return fmt.Errorf("archive write failed at %s: %w", perr.Path, err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling WriteArchive where file count > 0 (files staged fine) but ZipDir fails writing outPath — e.g. output directory doesn't exist, no write permission, outPath already exists as a directory, or disk full.

Common situations: Writing the archive to a read-only or nonexistent output directory, targeting a path with invalid characters/permissions, running out of disk space during zipping of large profiles, or antivirus locking the output 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 moonD4rk/HackBrowserData@0503d04d7a (2026-09-06). Data as JSON: /api/errors/3dead829ec4bd878. Report an issue: GitHub.