{"record":{"id":"e318f6e0a6346e92","repo":"spacedriveapp/spacedrive","slug":"failed-to-generate-content-hash","errorCode":null,"errorMessage":"Failed to generate content hash: {}","messagePattern":"Failed to generate content hash: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"core/src/ops/files/copy/strategy.rs","lineNumber":1081,"sourceCode":"\n\tlet file_size = metadata.len();\n\tcopy_single_file(\n\t\tsource,\n\t\tdestination,\n\t\tvolume_info,\n\t\tctx,\n\t\tverify_checksum,\n\t\tfile_size,\n\t\tprogress_callback,\n\t)\n\t.await\n}\n\n/// Calculate file checksum for integrity verification\nasync fn calculate_file_checksum(path: &Path) -> Result<String> {\n\tcrate::domain::content_identity::ContentHashGenerator::generate_content_hash(path)\n\t\t.await\n\t\t.map_err(|e| anyhow::anyhow!(\"Failed to generate content hash: {}\", e))\n}\n\n/// Stream file data in chunks to the remote device using a persistent connection\nasync fn stream_file_data<'a>(\n\tfile_path: &Path,\n\ttransfer_id: uuid::Uuid,\n\tfile_transfer_protocol: &crate::service::network::protocol::FileTransferProtocolHandler,\n\ttotal_size: u64,\n\tdestination_device_id: uuid::Uuid,\n\tdestination_path: String,\n\tfile_metadata: crate::service::network::protocol::FileMetadata,\n\tctx: &JobContext<'a>,\n\tprogress_callback: Option<&ProgressCallback<'a>>,\n) -> Result<()> {\n\tuse blake3::Hasher;\n\tuse tokio::io::{AsyncReadExt, AsyncWriteExt};\n\n\tdebug!(","sourceCodeStart":1063,"sourceCodeEnd":1099,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/core/src/ops/files/copy/strategy.rs#L1063-L1099","documentation":"calculate_file_checksum wraps a failure from ContentHashGenerator::generate_content_hash, invoked when verify_checksum is enabled for a copy to compute the local file's checksum for integrity verification. The underlying cause is almost always filesystem-level: the file could not be opened or read to completion. The anyhow context adds no new information beyond naming the hashing step.","triggerScenarios":"Calling copy with verify_checksum=true; between transfer completion and hashing the file is deleted, moved, exclusively locked by another process, or the daemon loses read permission; hashing a file truncated by an earlier interrupted write.","commonSituations":"Antivirus or another indexer holding exclusive locks on Windows; file consumed and deleted by an application immediately after arrival; permissions changed by a sync tool.","solutions":["Verify the file exists and the daemon user can read it at the logged path","Retry once - transient exclusive locks (antivirus scans) usually clear within seconds","Add library roots to antivirus real-time scanning exclusion lists","If integrity verification is optional for this workflow, run the job with verify_checksum disabled"],"exampleFix":"// before\nlet checksum = calculate_file_checksum(&path).await?;\n\n// after - degrade gracefully when verification is optional\nlet checksum = match calculate_file_checksum(&path).await {\n    Ok(c) => Some(c),\n    Err(e) if !require_verification => {\n        tracing::warn!(error = %e, \"checksum verify skipped\");\n        None\n    }\n    Err(e) => return Err(e),\n};","handlingStrategy":"retry","validationCode":"// Verify the file is readable before paying for a hash pass.\nlet f = tokio::fs::File::open(&path).await\n    .with_context(|| format!(\"cannot open for hashing: {}\", path.display()))?;\ndrop(f);","typeGuard":null,"tryCatchPattern":"// Transient read locks (antivirus, other indexers) clear quickly; retry once before failing.\nlet hash = match calculate_file_checksum(&path).await {\n    Ok(h) => h,\n    Err(first) => {\n        tokio::time::sleep(std::time::Duration::from_secs(2)).await;\n        calculate_file_checksum(&path).await.map_err(|_| first)?\n    }\n};","preventionTips":["Exclude library directories from antivirus real-time scanning","Ensure the daemon account has read access to destination paths","Avoid scheduling competing jobs over the same files"],"tags":["checksum","filesystem","copy","integrity"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}