feat: view folder's content in trash
- [x] I have disclosed use of any AI generated code in my commit messages. - If you are using an LLM, and do not fully understand the changes it is making to the code base, do not create a PR. - In our experience, AI generated code often results in overly complex code that lacks enough context for a proper fix or feature inclusion. This results in considerably longer code reviews. Due to this, AI authored or partially authored PRs may be closed without comment. - [x] I understand these changes in full and will be able to respond to review comments. - [x] My change is accurately described in the commit message. - [x] My contribution is tested and working as described. - [x] I have read the [Developer Certificate of Origin](https://developercertificate.org/) and certify my contribution under its conditions.
This commit is contained in:
parent
50deb28a11
commit
49107187a4
6 changed files with 154 additions and 29 deletions
36
src/tab.rs
36
src/tab.rs
|
|
@ -877,6 +877,8 @@ pub fn item_from_trash_entry(
|
|||
let name = entry.name.to_string_lossy().into_owned();
|
||||
let display_name = Item::display_name(&name);
|
||||
|
||||
let location = crate::trash::trash_item_path(&entry).map(Location::Path);
|
||||
|
||||
let (mime, icon_handle_grid, icon_handle_list, icon_handle_list_condensed) = match metadata.size
|
||||
{
|
||||
trash::TrashItemSize::Entries(_) => (
|
||||
|
|
@ -904,7 +906,7 @@ pub fn item_from_trash_entry(
|
|||
is_mount_point: false,
|
||||
metadata: ItemMetadata::Trash { metadata, entry },
|
||||
hidden: false,
|
||||
location_opt: None,
|
||||
location_opt: location,
|
||||
image_dimensions: (mime.type_() == mime::IMAGE)
|
||||
.then(|| image::image_dimensions(&original_path).ok())
|
||||
.flatten(),
|
||||
|
|
@ -925,6 +927,31 @@ pub fn item_from_trash_entry(
|
|||
}
|
||||
}
|
||||
|
||||
fn item_from_trash_child(
|
||||
path: PathBuf,
|
||||
name: String,
|
||||
metadata: fs::Metadata,
|
||||
sizes: IconSizes,
|
||||
) -> Option<Item> {
|
||||
let original_path = crate::trash::original_path_for_trash_child(&path)?;
|
||||
let entry = trash::TrashItem {
|
||||
id: path.as_os_str().to_os_string(),
|
||||
name: std::ffi::OsString::from(&name),
|
||||
original_parent: original_path.parent()?.to_path_buf(),
|
||||
time_deleted: 0,
|
||||
};
|
||||
let size = if metadata.is_dir() {
|
||||
trash::TrashItemSize::Entries(0)
|
||||
} else {
|
||||
trash::TrashItemSize::Bytes(metadata.len())
|
||||
};
|
||||
Some(item_from_trash_entry(
|
||||
entry,
|
||||
trash::TrashItemMetadata { size },
|
||||
sizes,
|
||||
))
|
||||
}
|
||||
|
||||
fn get_filename_from_path(path: &Path) -> Result<String, String> {
|
||||
Ok(match path.file_name() {
|
||||
Some(name_os) => name_os
|
||||
|
|
@ -1040,7 +1067,12 @@ pub fn scan_path(tab_path: &PathBuf, sizes: IconSizes) -> Vec<Item> {
|
|||
})
|
||||
.ok()?;
|
||||
|
||||
Some(item_from_entry(path, name, metadata, sizes))
|
||||
let trash = crate::trash::is_trash_path(tab_path);
|
||||
if trash {
|
||||
item_from_trash_child(path, name, metadata, sizes)
|
||||
} else {
|
||||
Some(item_from_entry(path, name, metadata, sizes))
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue