{"record":{"id":"9178e03c2256bf91","repo":"sxyazi/yazi","slug":"notfound","errorCode":"NotFound","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/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-fs/src/trash/macos/trash.rs#L84-L120","documentation":"Trash::restore moves each trashed item back to its recorded original location. If the entry's .DS_Store-derived put-back location is missing (original is None), the item cannot be restored and this NotFound error is returned.","triggerScenarios":"Calling Trash::restore with a TrashEntries list containing an entry whose `original` field is None — typically because the trash's .DS_Store lacked/failed to parse the put-back record for that item.","commonSituations":".DS_Store deleted or unreadable, item trashed by a tool that doesn't write put-back metadata, DsStore::parse fell back to default via unwrap_or_default.","solutions":["Ensure the trash .DS_Store contains valid put-back records for the item","Restore manually with mv to the desired path and update records","Filter entries with original == None before restoring and report them separately"],"exampleFix":"// before\ntrash.restore(entries)?;\n// after\nlet (restorable, missing): (Vec<_>, Vec<_>) = entries.into_iter().partition(|e| e.original.is_some());\nif !missing.is_empty() { eprintln!(\"cannot restore {} items\", missing.len()); }\ntrash.restore(restorable.into())?;","handlingStrategy":"validation","validationCode":"let restorable: Vec<_> = entries.iter().filter(|e| e.original.is_some()).collect();\nif restorable.len() != entries.len() { warn_about_missing_putback(); }","typeGuard":"fn has_putback(entry: &TrashEntry) -> bool { entry.original.is_some() }","tryCatchPattern":"match trash.restore(entries) {\n    Err(e) if e.kind() == io::ErrorKind::NotFound => prompt_manual_restore(),\n    other => other?,\n}","preventionTips":["Preserve the trash .DS_Store file","Avoid third-party tools that trash without writing put-back metadata","Partition entries by original.is_some() before batch restore"],"tags":["macos","trash","io","not-found"],"backgroundTag":"missing-trash-putback-location","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}