{"record":{"id":"3dead829ec4bd878","repo":"moonD4rk/HackBrowserData","slug":"write-archive-s-w","errorCode":null,"errorMessage":"write archive %s: %w","messagePattern":"write archive (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"browser/archive.go","lineNumber":65,"sourceCode":"\t\t\tseen[entry] = true\n\n\t\t\tdst := filepath.Join(staging, key, filepath.FromSlash(src.LayoutRel))\n\t\t\tif err := os.MkdirAll(filepath.Dir(dst), 0o755); err != nil {\n\t\t\t\tlog.Warnf(\"archive: %s: %v\", entry, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif err := session.Acquire(src.AbsPath, dst, src.IsDir); err != nil {\n\t\t\t\tlog.Warnf(\"archive: acquire %s: %v\", entry, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcount++\n\t\t}\n\t}\n\tif count == 0 {\n\t\treturn 0, fmt.Errorf(\"no decryption-relevant files found to archive\")\n\t}\n\tif err := fileutil.ZipDir(outPath, staging); err != nil {\n\t\treturn 0, fmt.Errorf(\"write archive %s: %w\", outPath, err)\n\t}\n\treturn count, nil\n}\n","sourceCodeStart":47,"sourceCodeEnd":69,"githubUrl":"https://github.com/moonD4rk/HackBrowserData/blob/0503d04d7a8d0379d060268a74f1b149e5a0aad5/browser/archive.go#L47-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the wrapped error (%w) from the message to identify the specific I/O cause.","Ensure the output directory exists and is writable: create it with os.MkdirAll before calling WriteArchive.","Check free disk space and that outPath doesn't collide with an existing directory.","Re-run with a different output path if the file is locked by another process/AV."],"exampleFix":"// before: output dir may not exist\nWriteArchive(profileDir, \"/tmp/out/archive.zip\")\n// after\nos.MkdirAll(\"/tmp/out\", 0o755)\nWriteArchive(profileDir, \"/tmp/out/archive.zip\")","handlingStrategy":"try-catch","validationCode":"if err := os.MkdirAll(filepath.Dir(outPath), 0o755); err != nil {\n    return err\n}\nif info, err := os.Stat(filepath.Dir(outPath)); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"output dir not writable\")\n}","typeGuard":null,"tryCatchPattern":"n, err := browser.WriteArchive(profileDir, outPath)\nvar perr *fs.PathError\nif err != nil {\n    if errors.As(err, &perr) {\n        return fmt.Errorf(\"archive write failed at %s: %w\", perr.Path, err)\n    }\n    return err\n}","preventionTips":["Create the output directory with os.MkdirAll before archiving.","Check available disk space for large profiles.","Ensure outPath doesn't collide with an existing directory.","Handle the wrapped fs.PathError for precise diagnostics."],"tags":["archive","file-write","zip","io"],"backgroundTag":"file-write-failed","analyzedSha":"0503d04d7a8d0379d060268a74f1b149e5a0aad5","analyzedAt":"2026-09-06T13:38:28.707Z","contentChangedAt":"2026-09-06T13:38:28.707Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}