{"record":{"id":"1539abca2e228f8f","repo":"sxyazi/yazi","slug":"cannot-write-cache-stamp-e","errorCode":null,"errorMessage":"Cannot write cache stamp: {e}","messagePattern":"Cannot write cache stamp: (.+?)","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"yazi-vfs/src/stamp.rs","lineNumber":61,"sourceCode":"\t\tlet stamp = Self::read_at(&path).await?;\n\t\tlet name = StrandCow::with(dir.loc().kind(), stamp.name()).map_err(io::Error::other)?;\n\n\t\tlet url = dir.try_join(name)?;\n\t\tif url.hash_u128_str(&mut [0; Self::SIG_LEN]).as_bytes() != key.encoded_bytes() {\n\t\t\treturn Err(io::Error::new(io::ErrorKind::InvalidData, \"Cache stamp does not match entry\"));\n\t\t}\n\n\t\tOk(url)\n\t}\n\n\tpub async fn write(cha: Cha, url: Url<'_>) -> io::Result<()> {\n\t\tlet path = url.stamp_entry().ok_or_else(|| io::Error::other(\"Cannot determine cache stamp\"))?;\n\t\tlet data = Self::encode(cha, url)?;\n\n\t\tLocal::regular(&path)\n\t\t\t.write(data)\n\t\t\t.await\n\t\t\t.map_err(|e| io::Error::new(e.kind(), format!(\"Cannot write cache stamp: {e}\")))\n\t}\n\n\tfn encode(cha: Cha, url: Url) -> io::Result<Vec<u8>> {\n\t\tlet name = url.name().ok_or_else(|| io::Error::other(\"URL has no filename\"))?;\n\n\t\tlet mut buf = Vec::with_capacity(Self::SIG_LEN + name.len());\n\t\tbuf.extend_from_slice(cha.hash_u128_str(&mut [0; Self::SIG_LEN]).as_bytes());\n\t\tbuf.extend_from_slice(name.encoded_bytes());\n\n\t\tOk(buf)\n\t}\n\n\tpub fn validate(&self, cha: Cha, url: Url) -> io::Result<()> {\n\t\tlet name = url.name().ok_or_else(|| io::Error::other(\"URL has no filename\"))?;\n\t\tif self.name() != name.encoded_bytes() {\n\t\t\treturn Err(io::Error::new(io::ErrorKind::InvalidData, \"Cache stamp does not match target\"));\n\t\t}\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/sxyazi/yazi/blob/8ebf930f1796ae2076b7d6b0c5e93a1002c18134/yazi-vfs/src/stamp.rs#L43-L79","documentation":"This io::Error wraps a failure while writing the encoded stamp bytes to the stamp entry path via Local::regular().write(). The OS error kind is preserved and its Display embedded as 'Cannot write cache stamp: {e}'. It is raised in Stamp::write after the stamp path is determined and data encoded successfully.","triggerScenarios":"Calling Stamp::write(cha, url) when url.stamp_entry() yields a path whose parent directory does not exist, is not writable, or the async write fails (disk full, permissions, I/O error).","commonSituations":"Cache directory deleted at runtime; read-only cache mount; disk quota/full disk while caching a downloaded remote file; permission misconfiguration on XDG cache dir.","solutions":["Create the cache/stamp parent directory before writing (ensure it exists and is writable)","Check free disk space and quotas on the cache volume","Fix permissions on the cache directory; retry the write after remediation"],"exampleFix":"// before\nStamp::write(cha, url).await?;\n// after\nif let Some(path) = url.stamp_entry() {\n    if let Some(parent) = path.parent() { tokio::fs::create_dir_all(parent).await?; }\n}\nStamp::write(cha, url).await?;","handlingStrategy":"try-catch","validationCode":"if let Some(path) = url.stamp_entry() {\n    if let Some(parent) = path.parent() {\n        tokio::fs::create_dir_all(parent).await?;\n    }\n}","typeGuard":"fn stamp_writable(path: &Path) -> bool {\n    path.parent().map(|p| p.is_dir()).unwrap_or(false)\n}","tryCatchPattern":"match Stamp::write(cha, url).await {\n    Ok(()) => (),\n    Err(e) if e.kind() == io::ErrorKind::StorageFull => warn_disk_full(),\n    Err(e) => return Err(e),\n}","preventionTips":["Create the cache parent directory before writing stamps","Monitor free disk space on the cache volume","Check cache dir permissions after system/account changes"],"tags":["io","filesystem","cache","write","rust"],"backgroundTag":"cache-file-write-failed","analyzedSha":"8ebf930f1796ae2076b7d6b0c5e93a1002c18134","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}