{"record":{"id":"6cd9022162617ea8","repo":"moonD4rk/HackBrowserData","slug":"file-is-empty","errorCode":null,"errorMessage":"file is empty","messagePattern":"file is empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"filemanager/copy_windows.go","lineNumber":117,"sourceCode":"\t\t}\n\t\t_ = windows.CloseHandle(dupHandle)\n\t}\n\n\treturn 0, fmt.Errorf(\"no process has file open: %s\", targetPath)\n}\n\n// readFileContent reads file content from a duplicated handle.\n// It uses FileMapping first (CreateFileMapping + MapViewOfFile), which reads\n// from the OS kernel's file cache — this includes WAL data that Chrome has\n// written but not yet checkpointed to the main file. Falls back to ReadFile\n// if FileMapping fails.\nfunc readFileContent(handle windows.Handle) ([]byte, error) {\n\tfileSize, err := winapi.GetFileSizeEx(handle)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif fileSize == 0 {\n\t\treturn nil, fmt.Errorf(\"file is empty\")\n\t}\n\n\tsize := int(fileSize)\n\n\t// Try FileMapping first — reads from kernel file cache, includes WAL data\n\tif data, err := winapi.MapFile(handle, size); err == nil {\n\t\treturn data, nil\n\t}\n\n\t// FileMapping failed, fall back to ReadFile.\n\t// Seek to beginning first — the handle's file pointer may be at an\n\t// arbitrary position.\n\tif _, err := windows.Seek(handle, 0, 0); err != nil {\n\t\treturn nil, fmt.Errorf(\"seek to start: %w\", err)\n\t}\n\tdata := make([]byte, size)\n\tvar bytesRead uint32\n\tif err := windows.ReadFile(handle, data, &bytesRead, nil); err != nil {","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/moonD4rk/HackBrowserData/blob/0503d04d7a8d0379d060268a74f1b149e5a0aad5/filemanager/copy_windows.go#L99-L135","documentation":"readFileContent queried the duplicated handle's size with GetFileSizeEx, got 0 bytes, and returned this guard error before attempting any mapping or read. It means the locked file is genuinely empty on disk (e.g. a freshly created but not-yet-flushed database, or all data still in the writer's WAL), so there is nothing to copy via this path.","triggerScenarios":"Thrown at filemanager/copy_windows.go:117 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Skip the copy and treat the source as having no data yet","Retry after the owning process flushes/checkpoints its writes","Read the companion -wal file instead if the data lives there","Confirm the duplicated handle refers to the intended file, not a truncated placeholder"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0503d04d7a8d0379d060268a74f1b149e5a0aad5","analyzedAt":"2026-09-06T13:38:28.707Z","contentChangedAt":"2026-09-06T13:38:28.707Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}