{"record":{"id":"505a9f394189ab57","repo":"Hmbown/CodeWhale","slug":"has-multiple-filesystem-links","errorCode":null,"errorMessage":"has multiple filesystem links","messagePattern":"has multiple filesystem links","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":13862,"sourceCode":"}\n\n#[cfg(windows)]\nfn runtime_store_file_identity(file: &File) -> Result<(u64, u64)> {\n    use std::os::windows::fs::MetadataExt as _;\n    use std::os::windows::io::AsRawHandle as _;\n    use windows_sys::Win32::Storage::FileSystem::{\n        BY_HANDLE_FILE_INFORMATION, FILE_ATTRIBUTE_REPARSE_POINT, GetFileInformationByHandle,\n    };\n\n    let metadata = file.metadata()?;\n    let safe = metadata.is_file() && metadata.file_attributes() & FILE_ATTRIBUTE_REPARSE_POINT == 0;\n    anyhow::ensure!(safe, \"not a regular non-reparse file\");\n    let mut info = BY_HANDLE_FILE_INFORMATION::default();\n    // SAFETY: the handle and writable output remain valid for the call.\n    if unsafe { GetFileInformationByHandle(file.as_raw_handle(), &mut info) } == 0 {\n        return Err(std::io::Error::last_os_error()).context(\"Inspect Runtime store file identity\");\n    }\n    anyhow::ensure!(info.nNumberOfLinks == 1, \"has multiple filesystem links\");\n    Ok((\n        u64::from(info.dwVolumeSerialNumber),\n        (u64::from(info.nFileIndexHigh) << 32) | u64::from(info.nFileIndexLow),\n    ))\n}\n\n#[cfg(all(not(unix), not(windows)))]\nfn runtime_store_file_identity(file: &File) -> Result<(u64, u64)> {\n    anyhow::ensure!(file.metadata()?.is_file(), \"must be a regular file\");\n    Ok((0, 0))\n}\n\nfn validate_same_runtime_store_file_handles(\n    first: &File,\n    second: &File,\n    path: &Path,\n) -> Result<()> {\n    let first = runtime_store_file_identity(first)?;","sourceCodeStart":13844,"sourceCodeEnd":13880,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L13844-L13880","documentation":"After confirming the file is a regular non-reparse file on Windows, `runtime_store_file_identity` calls GetFileInformationByHandle and requires nNumberOfLinks == 1 so the (volume, file-index) pair uniquely identifies a single file. If the file has more than one hard link, the same physical data exists under multiple names and the identity is ambiguous, so this error is raised.","triggerScenarios":"The opened store file has nNumberOfLinks > 1 because it was hard-linked elsewhere (e.g. by a backup tool using hard links, deduplication software, or a manual `mklink /H`).","commonSituations":"Windows hard-link-based backup/dedup tools (rsync-like, cherry-backup) linked store snapshots; user copied the store with a hard-link-preserving tool; version control or sync tools created links.","solutions":["Break the extra links: keep one path and delete the others, or copy the file (a real copy resets link count to 1) and use the new file","Disable or reconfigure hard-link-based backup/dedup tools that touch the store directory","Regenerate the store so it starts as a fresh single-link file"],"exampleFix":"// before: file is hard-linked by a backup tool, nlink = 2\nlet f = File::open(\"C:\\\\store\\\\runtime.bin\")?;\nlet id = runtime_store_file_identity(&f)?;\n// after: real copy resets link count to 1\nstd::fs::copy(\"C:\\\\store\\\\runtime.bin\", \"C:\\\\store\\\\runtime2.bin\")?;\nstd::fs::remove_file(\"C:\\\\store\\\\runtime.bin\")?;\nstd::fs::rename(\"C:\\\\store\\\\runtime2.bin\", \"C:\\\\store\\\\runtime.bin\")?;\nlet f = File::open(\"C:\\\\store\\\\runtime.bin\")?;\nlet id = runtime_store_file_identity(&f)?;","handlingStrategy":"validation","validationCode":"use windows_sys::Win32::Storage::FileSystem::GetFileInformationByHandle;\n// pre-check link count before identity computation\nlet meta = f.metadata()?;\nif !meta.is_file() { return Err(anyhow!(\"not a regular file\")); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = runtime_store_file_identity(&f) {\n    eprintln!(\"store is hard-linked; make a real copy: {e:#}\");\n}","preventionTips":["Copy (not hard-link) the store when duplicating","Disable hard-link dedup/backup tools on the store dir","After a real copy, nlink returns to 1"],"tags":["filesystem","windows","hard-link"],"backgroundTag":"incompatible-source-type","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}