{"record":{"id":"f08afd27fa8db73d","repo":"sxyazi/yazi","slug":"mtime-not-available","errorCode":null,"errorMessage":"mtime not available","messagePattern":"mtime not available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-fs/src/cha/cha.rs","lineNumber":202,"sourceCode":"\t\t\tOk(btime.duration_since(UNIX_EPOCH)?)\n\t\t} else {\n\t\t\tbail!(\"btime not available\");\n\t\t}\n\t}\n\n\tpub(crate) fn ctime_dur(self) -> anyhow::Result<Duration> {\n\t\tif let Some(ctime) = self.ctime {\n\t\t\tOk(ctime.duration_since(UNIX_EPOCH)?)\n\t\t} else {\n\t\t\tbail!(\"ctime not available\");\n\t\t}\n\t}\n\n\tpub fn mtime_dur(self) -> anyhow::Result<Duration> {\n\t\tif let Some(mtime) = self.mtime {\n\t\t\tOk(mtime.duration_since(UNIX_EPOCH)?)\n\t\t} else {\n\t\t\tbail!(\"mtime not available\");\n\t\t}\n\t}\n}\n","sourceCodeStart":184,"sourceCodeEnd":206,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-fs/src/cha/cha.rs#L184-L206","documentation":"Cha::mtime_dur converts the file's modification time to a Duration since the Unix epoch and bails when mtime is None. mtime is nearly always available, so hitting this means the Cha was constructed from a source that could not read modification time at all. Callers include add_fields and hash_u128.","triggerScenarios":"Calling mtime_dur() on a Cha built from a failed/incomplete stat (e.g. entries where metadata could not be read: permission-denied directories producing placeholder Cha, broken links handled by the platform path, virtual filesystem entries).","commonSituations":"Listing directories where some entries' stat fails due to permissions or races (file deleted between readdir and stat); broken symlinks resolved incorrectly; exotic network filesystems.","solutions":["Guard with mtime presence before calling and use a default/fallback display for unreadable entries.","Re-stat the file if the None may be transient (e.g. race with deletion).","Handle the error at the field-generation site so one bad entry doesn't abort the whole listing."],"exampleFix":"// before\nlet mtime = cha.mtime_dur()?;\n// after\nlet mtime = cha.mtime_dur().map(|d| d.as_millis()).unwrap_or(0);","handlingStrategy":"try-catch","validationCode":"if cha.mtime().is_none() { /* entry metadata unreadable; use placeholder */ }","typeGuard":"fn has_mtime(cha: Cha) -> bool { cha.mtime().is_some() }","tryCatchPattern":"let mtime = cha.mtime_dur().map(|d| d.as_millis()).unwrap_or(0); // placeholder for unreadable entries","preventionTips":["Expect stat races (file deleted between readdir and stat) in directory listings","Degrade gracefully for permission-denied entries instead of failing the batch","Use the Option accessor to check presence first"],"tags":["filesystem","metadata","mtime","missing-field"],"backgroundTag":"timestamp-not-available","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}