{"record":{"id":"c5c18d224b0352b1","repo":"sxyazi/yazi","slug":"trash-item-has-no-put-back-location-c5c18d","errorCode":null,"errorMessage":"trash item has no put-back location","messagePattern":"trash item has no put-back location","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"yazi-fs/src/trash/macos/trash.rs","lineNumber":102,"sourceCode":"\t\tlet changed = !latest.cha.hits(current.cha)\n\t\t\t|| latest.extra.link_to() != current.extra.link_to()\n\t\t\t|| latest.extra.backing() != current.extra.backing();\n\n\t\tOk(changed.then_some(latest))\n\t}\n\n\tpub(crate) fn remove_file(&self, entry: &TrashEntry) -> io::Result<()> {\n\t\tfs::remove_file(&entry.backing)\n\t}\n\n\tpub(crate) fn remove_dir(&self, entry: &TrashEntry) -> io::Result<()> {\n\t\tfs::remove_dir(&entry.backing)\n\t}\n\n\tpub(crate) fn restore(&self, entries: TrashEntries) -> io::Result<()> {\n\t\tfor entry in entries {\n\t\t\tlet to = entry.original.as_ref().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\trestore_item(&entry.backing, &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\tpub(crate) fn empty(&self) -> io::Result<()> {\n\t\tlet root = self.root()?;\n\t\tfor dent in ok_or_not_found!(fs::read_dir(root), return Ok(())) {\n\t\t\tlet dent = dent?;\n\t\t\tif dent.file_type()?.is_dir() {\n\t\t\t\tfs::remove_dir_all(dent.path())?;\n\t\t\t} else {","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/sxyazi/yazi/blob/94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2/yazi-fs/src/trash/macos/trash.rs#L84-L120","documentation":"Returned by Trash::restore on macOS when an entry's original (put-back) path is None, i.e. ~/.Trash/.DS_Store has no usable ptbL/ptbN record for it (errors 60-62 were swallowed earlier and left original empty). This is the user-visible form of 'cannot put back': yazi refuses to guess a destination and fails the whole restore batch with io::ErrorKind::NotFound.","triggerScenarios":"Restoring items that were moved into ~/.Trash by `mv`, shell scripts, or third-party tools that never write .DS_Store; restoring after .DS_Store was deleted/reset; restoring items whose ptbN failed the put-back-name validation.","commonSituations":"Power users trashing from the terminal and later trying 'put back' in yazi; cleanup utilities wiping .DS_Store; mixed selections where only some items lack put-back info — the first missing item aborts the loop, leaving earlier items already restored.","solutions":["Filter the selection: restore only entries with original ~= nil, and for the rest move them manually out of ~/.Trash or use Trash:rename to pick a destination.","If Finder put-back is important, move the item back and re-trash it from Finder, then restore.","Handle the (false, err) return of Trash:restore in Lua and report which items need manual handling instead of failing silently."],"exampleFix":"-- Lua: before\nlocal ok, err = ya.fs(\"trash\"):restore(entries)\n-- after: split restorable vs manual, keep the batch atomic from the user's view\nlocal trash = ya.fs(\"trash\")\nlocal restorable, manual = {}, {}\nfor _, e in ipairs(entries) do\n  (e.original and table.insert(restorable, e) or table.insert(manual, e))\nend\nif #restorable > 0 then local ok, err = trash:restore(restorable); end\n-- prompt the user for a destination for each entry in `manual`","handlingStrategy":"validation","validationCode":"-- Lua: partition before restoring\nlocal restorable, manual = {}, {}\nfor _, e in ipairs(entries) do\n  if e.original ~= nil then table.insert(restorable, e) else table.insert(manual, e) end\nend\nif #restorable > 0 then ya.fs(\"trash\"):restore(restorable) end","typeGuard":"local function is_restorable(e) return e.original ~= nil end","tryCatchPattern":"local ok, err = ya.fs(\"trash\"):restore(entries)\nif not ok then\n  ya.notify({ title = \"Restore failed\", content = tostring(err), level = \"warn\", timeout = 5 })\n  -- partial batch: re-list the trash to see what moved and what stayed\nend","preventionTips":["Pre-filter on original ~= nil; restore is all-or-nothing per item and fails the batch.","For entries without put-back info, use rename to an explicit destination as the manual path.","Remember restore also fails with AlreadyExists if the target path exists — check the destination too."],"tags":["trash","macos","put-back","restore","ds-store"],"backgroundTag":null,"analyzedSha":"94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2","analyzedAt":"2026-08-16T09:56:24.836Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}