{"record":{"id":"64e25316ecba1b03","repo":"sxyazi/yazi","slug":"directorynotempty","errorCode":"DirectoryNotEmpty","errorMessage":"trash directory is not empty","messagePattern":"trash directory is not empty","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"yazi-fs/src/trash/windows/trash.rs","lineNumber":91,"sourceCode":"\t\tlet cha = if let Some(entry) = entry {\n\t\t\tTrashSig::item(&self.resolve(entry)?)?\n\t\t} else {\n\t\t\tTrashSig::root()?\n\t\t};\n\n\t\tOk(if cha.hits(current.cha) { None } else { Some(File { cha, ..current.clone() }) })\n\t}\n\n\tpub(crate) fn remove_file(&self, entry: &TrashEntry) -> io::Result<()> {\n\t\tself.resolve(entry)?.delete()\n\t}\n\n\tpub(crate) fn remove_dir(&self, entry: &TrashEntry) -> io::Result<()> {\n\t\tlet item = self.resolve(entry)?;\n\t\tif !entry.has_rel() {\n\t\t\titem.delete()\n\t\t} else if !item.is_empty()? {\n\t\t\tErr(io::Error::new(io::ErrorKind::DirectoryNotEmpty, \"trash directory is not empty\"))\n\t\t} else {\n\t\t\titem.delete()\n\t\t}\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_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)","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-fs/src/trash/windows/trash.rs#L73-L109","documentation":"Windows trash removal guard in `Trash::remove_dir`: the entry refers to a trash sub-directory whose resolved item still contains files. To avoid destroying unrecoverable content, directory entries are only removed when empty; otherwise `DirectoryNotEmpty` is returned.","triggerScenarios":"Thrown at yazi-fs/src/trash/windows/trash.rs:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Empty the trash directory first (remove its contained items).","Remove the individual items inside the directory instead of the directory itself."],"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"}