{"record":{"id":"af38fd14793a034b","repo":"sxyazi/yazi","slug":"alreadyexists","errorCode":"AlreadyExists","errorMessage":"restore target already exists: {to:?}","messagePattern":"restore target already exists: (.+?)","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"yazi-fs/src/trash/windows/trash.rs","lineNumber":115,"sourceCode":"\tpub(crate) fn restore(&self, entries: TrashEntries) -> io::Result<()> {\n\t\tfor entry in entries {\n\t\t\tlet to = entry.original.as_deref().ok_or_else(|| {\n\t\t\t\tio::Error::new(io::ErrorKind::NotFound, \"trash item has no put-back location\")\n\t\t\t})?;\n\n\t\t\tself.restore_do(&self.resolve(&entry)?, to)?;\n\t\t}\n\t\tOk(())\n\t}\n\n\tpub(crate) fn rename(&self, entry: &TrashEntry, path: &Path) -> io::Result<()> {\n\t\tfs::rename(&entry.backing, path)\n\t}\n\n\tfn restore_do(&self, item: &ShellItem, to: &Path) -> io::Result<()> {\n\t\tmatch fs::symlink_metadata(to) {\n\t\t\tOk(_) => {\n\t\t\t\treturn Err(io::Error::new(\n\t\t\t\t\tio::ErrorKind::AlreadyExists,\n\t\t\t\t\tformat!(\"restore target already exists: {to:?}\"),\n\t\t\t\t));\n\t\t\t}\n\t\t\tErr(e) if e.kind() == io::ErrorKind::NotFound => {}\n\t\t\tErr(e) => return Err(e),\n\t\t}\n\n\t\t// Create parent directories\n\t\tlet parent = to\n\t\t\t.parent()\n\t\t\t.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, \"invalid restore target\"))?;\n\t\tfs::create_dir_all(parent)?;\n\n\t\tlet parent = ShellItem::new(parent)?;\n\t\tlet name: Vec<u16> = to\n\t\t\t.file_name()\n\t\t\t.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, \"invalid restore target\"))?","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-fs/src/trash/windows/trash.rs#L97-L133","documentation":"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.","triggerScenarios":"Thrown at yazi-fs/src/trash/windows/trash.rs:115 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}