sxyazi/yazi · error

mtime not available

Error message

mtime not available

What it means

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.

Source

Thrown at yazi-fs/src/cha/cha.rs:202

			Ok(btime.duration_since(UNIX_EPOCH)?)
		} else {
			bail!("btime not available");
		}
	}

	pub(crate) fn ctime_dur(self) -> anyhow::Result<Duration> {
		if let Some(ctime) = self.ctime {
			Ok(ctime.duration_since(UNIX_EPOCH)?)
		} else {
			bail!("ctime not available");
		}
	}

	pub fn mtime_dur(self) -> anyhow::Result<Duration> {
		if let Some(mtime) = self.mtime {
			Ok(mtime.duration_since(UNIX_EPOCH)?)
		} else {
			bail!("mtime not available");
		}
	}
}

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Guard with mtime presence before calling and use a default/fallback display for unreadable entries.
  2. Re-stat the file if the None may be transient (e.g. race with deletion).
  3. Handle the error at the field-generation site so one bad entry doesn't abort the whole listing.

Example fix

// before
let mtime = cha.mtime_dur()?;
// after
let mtime = cha.mtime_dur().map(|d| d.as_millis()).unwrap_or(0);
Defensive patterns

Strategy: try-catch

Validate before calling

if cha.mtime().is_none() { /* entry metadata unreadable; use placeholder */ }

Type guard

fn has_mtime(cha: Cha) -> bool { cha.mtime().is_some() }

Try / catch

let mtime = cha.mtime_dur().map(|d| d.as_millis()).unwrap_or(0); // placeholder for unreadable entries

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02). Data as JSON: /api/errors/f08afd27fa8db73d. Report an issue: GitHub.