sxyazi/yazi · error · io::Error
AlreadyExists
AlreadyExists
Error message
restore target already exists: {to:?} What it means
Restore guard in `Trash::restore_do`: `fs::symlink_metadata` on the put-back target path succeeded, meaning something already exists at the original location. Restoring would overwrite it, so the operation is refused with `AlreadyExists`. The faulting input is the `to` path.
Source
Thrown at yazi-fs/src/trash/windows/trash.rs:115
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)
}
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: Vec<u16> = to
.file_name()
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, "invalid restore target"))?View on GitHub (pinned to 5f901b886b)
Solutions
- Move or delete the existing file/folder at the target path, then restore again.
- Rename the conflicting item before restoring from trash.
- Choose a different restore location if the trash implementation supports it.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at yazi-fs/src/trash/windows/trash.rs:115 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02).
Data as JSON: /api/errors/af38fd14793a034b.
Report an issue: GitHub.