sxyazi/yazi · error · io::Error

DirectoryNotEmpty

DirectoryNotEmpty

Error message

trash directory is not empty

What it means

Windows trash removal guard in `Trash::remove_dir`: the entry refers to a trash sub-directory whose resolved item still contains files. To avoid destroying unrecoverable content, directory entries are only removed when empty; otherwise `DirectoryNotEmpty` is returned.

Solutions

  1. Empty the trash directory first (remove its contained items).
  2. Remove the individual items inside the directory instead of the directory itself.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at yazi-fs/src/trash/windows/trash.rs:91 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at yazi-fs/src/trash/windows/trash.rs:92

		let cha = if let Some(entry) = entry {
			TrashSig::item(&self.resolve(entry)?)?
		} else {
			TrashSig::root()?
		};

		Ok(if cha.hits(current.cha) { None } else { Some(File { cha, ..current.clone() }) })
	}

	pub(crate) fn remove_file(&self, entry: &TrashEntry) -> io::Result<()> {
		self.resolve(entry)?.delete()
	}

	pub(crate) fn remove_dir(&self, entry: &TrashEntry) -> io::Result<()> {
		let item = self.resolve(entry)?;
		if !entry.has_rel() {
			item.delete()
		} else if !item.is_empty()? {
			Err(io::Error::new(io::ErrorKind::DirectoryNotEmpty, "trash directory is not empty"))
		} else {
			item.delete()
		}
	}

	pub(crate) fn restore(&self, entries: TrashEntries) -> io::Result<()> {
		for entry in entries {
			let to = entry.original.as_deref().ok_or_else(|| {
				io::Error::new(io::ErrorKind::NotFound, "trash item has no put-back location")
			})?;

			self.restore_do(&self.resolve(&entry)?, to)?;
		}
		Ok(())
	}

	pub(crate) fn rename(&self, entry: &TrashEntry, path: &Path) -> io::Result<()> {
		fs::rename(&entry.backing, path)

View on GitHub (pinned to a541adde4e)