{"record":{"id":"29d1da2132d6069c","repo":"moonD4rk/HackBrowserData","slug":"copy-w","errorCode":null,"errorMessage":"copy: %w","messagePattern":"copy: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"filemanager/session.go","lineNumber":49,"sourceCode":"// Acquire copies a browser file (or directory) from src to dst.\n// For regular files, it also copies SQLite WAL and SHM companion files\n// if they exist. For directories (e.g. LevelDB), it copies the entire\n// directory while skipping lock files.\n//\n// On Windows, if the normal copy fails (e.g. file locked by Chrome),\n// it falls back to DuplicateHandle + FileMapping to bypass exclusive locks.\nfunc (s *Session) Acquire(src, dst string, isDir bool) error {\n\tif isDir {\n\t\treturn copyDir(src, dst, \"lock\")\n\t}\n\n\t// Try normal copy first\n\terr := copyFile(src, dst)\n\tif err != nil {\n\t\t// Only attempt locked-file fallback on Windows where Chrome holds exclusive locks.\n\t\t// On other platforms, return the original error directly.\n\t\tif runtime.GOOS != \"windows\" {\n\t\t\treturn fmt.Errorf(\"copy: %w\", err)\n\t\t}\n\t\tif err2 := copyLocked(src, dst); err2 != nil {\n\t\t\treturn errors.Join(\n\t\t\t\tfmt.Errorf(\"copy: %w\", err),\n\t\t\t\tfmt.Errorf(\"locked copy: %w\", err2),\n\t\t\t)\n\t\t}\n\t}\n\n\t// Copy SQLite WAL/SHM companion files if present\n\tvar walErrs []error\n\tfor _, suffix := range []string{\"-wal\", \"-shm\"} {\n\t\twalSrc := src + suffix\n\t\tif isFileExists(walSrc) {\n\t\t\tif err := copyFile(walSrc, dst+suffix); err != nil {\n\t\t\t\twalErrs = append(walErrs, fmt.Errorf(\"copy %s: %w\", suffix, err))\n\t\t\t}\n\t\t}","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/moonD4rk/HackBrowserData/blob/0503d04d7a8d0379d060268a74f1b149e5a0aad5/filemanager/session.go#L31-L67","documentation":"Acquire wraps a copyFile failure with \"copy: %w\" when the platform is NOT Windows. On non-Windows systems there is no locked-file fallback, so any error from the plain file copy (open, read, or write failure) is surfaced under this prefix. On Windows this same prefix appears as one branch of a joined error when both the normal copy and the locked copy failed.","triggerScenarios":"Session.Acquire(src, dst, false) on Linux/macOS where copyFile fails: source file missing, source unreadable (permissions), destination not writable, or destination directory missing. On Windows it also appears whenever copyLocked also fails, producing errors.Join of both errors.","commonSituations":"Browser profile path changed in a recent browser version; running without read access to another user's profile; disk full; the SQLite database deleted while the browser was updating; destination temp dir removed mid-run.","solutions":["Verify the source file path exists and is readable by the current user (ls -l the profile directory).","Ensure the destination (session temp dir) still exists and is writable — call session.Cleanup() only after extraction completes.","Free disk space if the copy failed on write.","On Windows, also read the joined \"locked copy:\" branch of the error to see why the fallback failed; restarting the browser or retrying often clears transient locks."],"exampleFix":"// before\nif err := s.Acquire(src, dst, false); err != nil {\n    log.Fatalf(\"acquire failed: %v\", err)\n}\n// after\nif err := s.Acquire(src, dst, false); err != nil {\n    if _, statErr := os.Stat(src); statErr != nil {\n        log.Warnf(\"source missing, skipping: %v\", statErr)\n        return nil\n    }\n    return fmt.Errorf(\"acquire %s: %w\", src, err)\n}","handlingStrategy":"validation","validationCode":"// pre-check source readability and destination writability\nif fi, err := os.Stat(src); err != nil || fi.IsDir() {\n    return fmt.Errorf(\"src %s not a readable file: %w\", src, err)\n}\nif err := os.MkdirAll(filepath.Dir(dst), 0o700); err != nil {\n    return fmt.Errorf(\"dst dir: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"// Go\nif err := s.Acquire(src, dst, false); err != nil {\n    var pathErr *os.PathError\n    if errors.As(err, &pathErr) {\n        log.Warnf(\"filesystem error on %s: %v\", pathErr.Path, pathErr.Err)\n    }\n    return err\n}","preventionTips":["Verify profile paths for the installed browser version before extraction","Run with read access to the target user's profile","Keep disk space above a safe threshold"],"tags":["file-copy","filesystem","cross-platform","permissions"],"backgroundTag":"file-read-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"}