sxyazi/yazi · error · io::Error

invalid restore target

Error message

invalid restore target

What it means

Error "invalid restore target" thrown in sxyazi/yazi.

Solutions

  1. The recorded restore target path is invalid; restore the item manually from the Recycle Bin.

When it happens

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

Common situations: Restoring to a target path that is invalid or fails validation on Windows.


AI-assisted analysis of sxyazi/yazi@a541adde4e (2026-08-19). Data as JSON: /api/errors/f49d86b38701f97b. Report an issue: GitHub.

Appendix: source

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

		fs::rename(&entry.backing, path)
	}

	fn restore_do(&self, item: &ShellItem, to: &Path) -> io::Result<()> {
		match fs::symlink_metadata(to) {
			Ok(_) => {
				return Err(io::Error::new(
					io::ErrorKind::AlreadyExists,
					format!("restore target already exists: {to:?}"),
				));
			}
			Err(e) if e.kind() == io::ErrorKind::NotFound => {}
			Err(e) => return Err(e),
		}

		// Create parent directories
		let parent = to
			.parent()
			.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, "invalid restore target"))?;
		fs::create_dir_all(parent)?;

		let parent = ShellItem::new(parent)?;
		let name = to
			.file_name()
			.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, "invalid restore target"))?
			.to_wide();

		operate(FOF_NO_UI | FOFX_EARLYFAILURE, |operation| unsafe {
			operation.MoveItem(&item.0, &parent.0, PCWSTR(name.as_ptr()), None)
		})
	}

	pub(crate) fn empty(&self) -> io::Result<()> {
		unsafe {
			SHEmptyRecycleBinW(
				None,
				PCWSTR::null(),

View on GitHub (pinned to a541adde4e)