fix(trash): list a large trash, empty it, and browse it by folder

A large trash never finished listing, so the Trash page kept the rows of
the last refresh that got anywhere, and Empty Trash listed the trash before
sending the delete and hung there (B293). The paging fix is in
proton-drive-rs 0.12.5.

- The refresh reads only nodes it has not stored yet, without unlocking
  file keys, keeps the time the server says each was trashed, and drops
  rows only once the whole listing is in.
- Empty Trash sends the delete at once under the trash call time limit
  and clears the stored listing. Restore and Delete Permanently drop their
  rows right away.
- Schema v47 indexes trash.parent_uid and drops the stored rows once, so
  they are read again with real deletion times.
- The Trash page groups items by the folder they were deleted from, opens
  deleted folders through the new ListTrashedFolder request, and has a
  search box and a switch back to one list. Restore and Delete Permanently
  on a folder row act on everything deleted from it.
- pdfs trash takes --by-folder and --folder UID.
This commit is contained in:
nvrl committed 2026-11-22 02:38:48 +01:00
1 parent f141d88d97
commit d0f9681593
30 files changed
+2661 -1306

No files matched your search

+7
View File
@@ -547,6 +547,13 @@ fn build_window(app: &adw::Application) {
selection_bar: trash_widgets.selection_bar.clone(),
selection_label: trash_widgets.selection_label.clone(),
loader: Loader::new(&trash_widgets.content),
back: trash_widgets.back.clone(),
crumb: trash_widgets.crumb.clone(),
search: trash_widgets.search.clone(),
grouped: trash_widgets.grouped.clone(),
all: RefCell::new(Vec::new()),
nav: RefCell::new(Vec::new()),
folder_rows: RefCell::new(None),
},
gallery: GalleryState {
model: gallery_widgets.model.clone(),
+2
View File
@@ -3185,6 +3185,7 @@ pub(crate) fn repaint_search(ui: &Rc<Ui>, hits: &[SearchHit]) {
shared_by_unverified: false,
trashed_at: 0,
trashed_from: None,
trashed_parent: None,
issue: None,
})
.collect();
@@ -3249,6 +3250,7 @@ mod tests {
shared_by_unverified: false,
trashed_at: 0,
trashed_from: None,
trashed_parent: None,
issue: None,
}
}
@@ -635,6 +635,7 @@ pub(crate) fn shared_item_as_entry(item: &SharedItem) -> DirEntry {
shared_by_unverified: false,
trashed_at: 0,
trashed_from: None,
trashed_parent: None,
issue: None,
}
}
+503 -24
View File
@@ -16,6 +16,28 @@ pub(crate) struct TrashState {
pub(crate) selection_label: gtk4::Label,
/// Runs the loads; the rows stay up while one runs.
pub(crate) loader: Rc<Loader>,
/// Back, the breadcrumb and the search entry over the list.
pub(crate) back: gtk4::Button,
pub(crate) crumb: gtk4::Box,
pub(crate) search: gtk4::SearchEntry,
/// On: the trash as the folders things were deleted from. Off: one list.
pub(crate) grouped: gtk4::ToggleButton,
/// The whole trash as last read, newest deletion first.
pub(crate) all: RefCell<Vec<DirEntry>>,
/// Where the list is, below the top level.
pub(crate) nav: RefCell<Vec<TrashNav>>,
/// What the trashed folder on screen holds, once read.
pub(crate) folder_rows: RefCell<Option<Vec<DirEntry>>>,
}
/// One step down from the top of the Trash page.
#[derive(Clone, Debug, PartialEq)]
pub(crate) enum TrashNav {
/// The things deleted from one folder: its path, `""` for My files, `None`
/// when the folder is not known.
Location { key: Option<String>, label: String },
/// Inside a trashed folder.
Folder { uid: String, name: String },
}
/// The widgets of the Trash page that a load repaints.
@@ -30,8 +52,18 @@ pub(crate) struct TrashWidgets {
pub(crate) selection_label: gtk4::Label,
pub(crate) restore_selected: gtk4::Button,
pub(crate) delete_selected: gtk4::Button,
pub(crate) back: gtk4::Button,
pub(crate) crumb: gtk4::Box,
pub(crate) search: gtk4::SearchEntry,
pub(crate) grouped: gtk4::ToggleButton,
}
/// The uid prefix of a row that stands for a folder things were deleted from.
/// Such a row is made here, never sent to the daemon.
const LOCATION_UID: &str = "trash-location:";
/// The location key of the folder that is not known.
const UNKNOWN_LOCATION: &str = "\u{0}";
/// The Trash page: everything Drive is holding in the trash, as a list with
/// the folder each item came from and when it was deleted, or as a grid, where
/// photos are easier to recognise. Restore and Delete Permanently sit in the
@@ -75,11 +107,41 @@ pub(crate) fn build_trash_page() -> (gtk4::Widget, TrashWidgets) {
content.add_named(&files.views, Some("list"));
content.add_named(&status, Some("status"));
let back = gtk4::Button::builder()
.icon_name("go-previous-symbolic")
.tooltip_text(gettext("Back"))
.visible(false)
.build();
back.add_css_class("flat");
let crumb = gtk4::Box::new(gtk4::Orientation::Horizontal, 2);
crumb.set_valign(gtk4::Align::Center);
let crumb_scroll = gtk4::ScrolledWindow::builder()
.hscrollbar_policy(gtk4::PolicyType::External)
.vscrollbar_policy(gtk4::PolicyType::Never)
.hexpand(true)
.child(&crumb)
.build();
let search = gtk4::SearchEntry::builder()
.placeholder_text(gettext("Search the trash"))
.width_chars(24)
.build();
let path_bar = gtk4::Box::new(gtk4::Orientation::Horizontal, 8);
path_bar.append(&back);
path_bar.append(&crumb_scroll);
path_bar.append(&search);
let grouped = gtk4::ToggleButton::builder()
.icon_name("folder-symbolic")
.tooltip_text(gettext("Group by original folder"))
.active(true)
.build();
let inner = gtk4::Box::new(gtk4::Orientation::Vertical, 12);
inner.set_margin_top(12);
inner.set_margin_bottom(12);
inner.set_margin_start(12);
inner.set_margin_end(12);
inner.append(&path_bar);
inner.append(&content);
// Bulk Delete Permanently always confirms with the count, so a stale
@@ -101,6 +163,7 @@ pub(crate) fn build_trash_page() -> (gtk4::Widget, TrashWidgets) {
let (frame, header, subtitle) = page_frame(&gettext("Trash"), &inner);
header.pack_start(&empty);
header.pack_end(&layout);
header.pack_end(&grouped);
(
frame.upcast(),
@@ -115,6 +178,10 @@ pub(crate) fn build_trash_page() -> (gtk4::Widget, TrashWidgets) {
selection_label,
restore_selected,
delete_selected,
back,
crumb,
search,
grouped,
},
)
}
@@ -151,7 +218,10 @@ pub(crate) fn wire_trash(ui: &Rc<Ui>, widgets: &TrashWidgets) {
files
.column_view
.append_column(&text_column(&pgettext("column", "Size"), |e| {
if e.is_dir {
if location_key(&e.uid).is_some() {
// A location row carries how many items it holds as its size.
ngettext_f("{n} item", "{n} items", e.size, &[])
} else if e.is_dir {
"—".to_string()
} else {
human_bytes(e.size)
@@ -163,6 +233,21 @@ pub(crate) fn wire_trash(ui: &Rc<Ui>, widgets: &TrashWidgets) {
.empty
.connect_clicked(move |_| prompt_empty_trash(&ui_empty));
let ui_back = ui.clone();
widgets.back.connect_clicked(move |_| {
ui_back.trash.nav.borrow_mut().pop();
show_trash_place(&ui_back);
});
let ui_search = ui.clone();
widgets
.search
.connect_search_changed(move |_| render_trash(&ui_search));
let ui_grouped = ui.clone();
widgets.grouped.connect_toggled(move |_| {
ui_grouped.trash.nav.borrow_mut().clear();
show_trash_place(&ui_grouped);
});
let ui_sel = ui.clone();
files
.selection
@@ -193,17 +278,52 @@ fn trashed_from_label(entry: &DirEntry) -> String {
}
}
/// A trashed file can't be opened; say what would let it be.
/// Open a location or a trashed folder in place. A trashed file can't be
/// opened; say what would let it be.
fn activate_trashed(ui: &Rc<Ui>, entry: &DirEntry) {
toast(
ui,
if let Some(key) = location_key(&entry.uid) {
ui.trash.nav.borrow_mut().push(TrashNav::Location {
key,
label: entry.name.clone(),
});
show_trash_place(ui);
} else if entry.is_dir {
ui.trash.nav.borrow_mut().push(TrashNav::Folder {
uid: entry.uid.clone(),
name: entry.name.clone(),
});
show_trash_place(ui);
} else {
let name = match outer_folder(ui) {
Some(folder) if !in_trash(ui, &entry.uid) => folder.name,
_ => entry.name.clone(),
};
// Translators: {name} is a file or folder name.
&gettext_f("Restore “{name}” to open it", &[("name", &entry.name)]),
);
toast(
ui,
&gettext_f("Restore “{name}” to open it", &[("name", &name)]),
);
}
}
fn trash_entry_menu(ui: &Rc<Ui>, entry: &DirEntry) -> ActionMenu {
let mut menu = ActionMenu::new();
if location_key(&entry.uid).is_none()
&& !in_trash(ui, &entry.uid)
&& let Some(folder) = outer_folder(ui)
{
// Went to the trash with the folder, so only the folder goes back.
let ui_c = ui.clone();
let label = gettext_f(
// Translators: {name} is a folder name.
"Restore “{name}”",
&[("name", &folder.name)],
);
menu.item(&label, move || {
restore_entries(&ui_c, std::slice::from_ref(&folder))
});
return menu;
}
let (ui_c, entry_c) = (ui.clone(), entry.clone());
menu.item(&pgettext("verb", "Restore"), move || {
restore_entries(&ui_c, std::slice::from_ref(&entry_c))
@@ -244,7 +364,7 @@ fn trash_background_menu(ui: &Rc<Ui>) -> ActionMenu {
});
let ui_c = ui.clone();
menu.item(&gettext("Refresh"), move || reload_current_page(&ui_c));
if ui.trash.files.model.n_items() > 0 {
if !ui.trash.all.borrow().is_empty() {
menu.section();
let ui_c = ui.clone();
menu.item(&gettext("Empty Trash…"), move || {
@@ -300,7 +420,17 @@ pub(crate) fn load_trash(ui: &Rc<Ui>) {
clear_trash(&ui);
}
match result {
Ok(Ok(Response::Entries { entries })) => repaint_trash(&ui, &entries),
Ok(Ok(Response::Entries { entries })) => {
let mut entries = entries;
sort_trash(&mut entries);
*ui.trash.all.borrow_mut() = entries;
keep_trash_place(&ui);
if matches!(ui.trash.nav.borrow().last(), Some(TrashNav::Folder { .. })) {
load_trashed_folder(&ui);
} else {
render_trash(&ui);
}
}
Ok(Ok(Response::Error { message, .. })) => trash_status(
&ui,
"dialog-warning-symbolic",
@@ -338,14 +468,125 @@ pub(crate) fn trash_status(ui: &Rc<Ui>, icon: &str, title: &str, description: &s
ui.trash.subtitle.set_subtitle("");
}
/// Repopulate the trash, most recently deleted first: the order in which a user
/// looks for what they just deleted.
pub(crate) fn repaint_trash(ui: &Rc<Ui>, entries: &[DirEntry]) {
/// Go to the place `nav` now points at: read a trashed folder, or show
/// what the stored listing already holds.
fn show_trash_place(ui: &Rc<Ui>) {
if !ui.trash.search.text().is_empty() {
ui.trash.search.set_text("");
}
ui.trash.files.selection.unselect_all();
ui.trash.files.scroll_to_top();
if matches!(ui.trash.nav.borrow().last(), Some(TrashNav::Folder { .. })) {
load_trashed_folder(ui);
} else {
render_trash(ui);
}
}
/// Read what the trashed folder on screen holds, then show it.
fn load_trashed_folder(ui: &Rc<Ui>) {
let Some(TrashNav::Folder { uid, .. }) = ui.trash.nav.borrow().last().cloned() else {
return;
};
ui.trash.folder_rows.borrow_mut().take();
let ui_p = ui.clone();
let ticket = ui.trash.loader.replace(move || {
clear_trash(&ui_p);
trash_status(
&ui_p,
"folder-open-symbolic",
&gettext("Loading…"),
&gettext("Reading this folder."),
false,
);
});
ui.busy_begin();
let rx = spawn_request(
ui.dirs.control_socket(),
Request::ListTrashedFolder { uid: uid.clone() },
);
let ui = ui.clone();
glib::spawn_future_local(async move {
let result = rx.recv().await;
ui.busy_end();
if !ticket.is_current() {
return;
}
let still_here = matches!(
ui.trash.nav.borrow().last(),
Some(TrashNav::Folder { uid: on, .. }) if *on == uid
);
if !still_here {
return;
}
match result {
Ok(Ok(Response::Entries { entries })) => {
*ui.trash.folder_rows.borrow_mut() = Some(entries);
render_trash(&ui);
}
Ok(Ok(Response::Error { message, .. })) => {
clear_trash(&ui);
trash_status(
&ui,
"dialog-warning-symbolic",
&gettext("Couldn't open the folder"),
&message,
false,
);
}
Ok(Ok(_)) => {
clear_trash(&ui);
trash_status(
&ui,
"dialog-warning-symbolic",
&gettext("Couldn't open the folder"),
&gettext("Unexpected reply from the Proton Drive service."),
false,
);
}
Ok(Err(_)) | Err(_) => trash_unreachable(&ui),
}
});
}
/// After a new listing, step back out of places that are gone from it.
fn keep_trash_place(ui: &Rc<Ui>) {
let all = ui.trash.all.borrow();
let mut nav = ui.trash.nav.borrow_mut();
let keep = kept_steps(&nav, &all);
nav.truncate(keep);
}
/// How many steps of `nav` still lead somewhere in `all`. A location stays
/// while something deleted from it is listed, and the trashed folder opened
/// from it while that folder is; the folders below it went with it.
fn kept_steps(nav: &[TrashNav], all: &[DirEntry]) -> usize {
let mut inside = false;
for (i, step) in nav.iter().enumerate() {
let there = match step {
TrashNav::Location { key, .. } => all
.iter()
.any(|e| e.trashed_parent.is_none() && e.trashed_from == *key),
TrashNav::Folder { uid, .. } => inside || all.iter().any(|e| e.uid == *uid),
};
if !there {
return i;
}
inside |= matches!(step, TrashNav::Folder { .. });
}
nav.len()
}
/// Show the rows for the current place, search and grouping.
pub(crate) fn render_trash(ui: &Rc<Ui>) {
let all = ui.trash.all.borrow();
// An empty Trash has nothing to empty, so the button goes away rather than
// sitting there greyed out.
ui.trash.empty.set_sensitive(true);
ui.trash.empty.set_visible(!entries.is_empty());
if entries.is_empty() {
ui.trash.empty.set_visible(!all.is_empty());
repaint_trash_crumb(ui);
if all.is_empty() {
drop(all);
trash_status(
ui,
"user-trash-symbolic",
@@ -356,22 +597,198 @@ pub(crate) fn repaint_trash(ui: &Rc<Ui>, entries: &[DirEntry]) {
clear_trash(ui);
return;
}
ui.trash.content.set_visible_child_name("list");
ui.trash.subtitle.set_subtitle(&ngettext_f(
"{n} item",
"{n} items",
entries.len() as u64,
&[],
));
let subtitle = ngettext_f("{n} item", "{n} items", all.len() as u64, &[]);
let mut sorted = entries.to_vec();
sort_trash(&mut sorted);
let query = ui.trash.search.text().to_lowercase();
let nav = ui.trash.nav.borrow().clone();
let rows: Vec<DirEntry> = if !query.is_empty() {
all.iter()
.filter(|e| e.name.to_lowercase().contains(&query))
.cloned()
.collect()
} else if !ui.trash.grouped.is_active() {
all.clone()
} else {
match nav.last() {
None => trash_locations(&all),
Some(TrashNav::Location { key, .. }) => all
.iter()
.filter(|e| e.trashed_parent.is_none() && e.trashed_from == *key)
.cloned()
.collect(),
Some(TrashNav::Folder { .. }) => {
ui.trash.folder_rows.borrow().clone().unwrap_or_default()
}
}
};
drop(all);
if rows.is_empty() {
clear_trash(ui);
if query.is_empty() {
trash_status(
ui,
"folder-open-symbolic",
&gettext("This folder is empty"),
&gettext("Nothing else was in this folder when it was deleted."),
false,
);
} else {
trash_status(
ui,
"edit-find-symbolic",
&gettext("No results"),
&gettext("Nothing in the trash has that name."),
false,
);
}
ui.trash.subtitle.set_subtitle(&subtitle);
return;
}
ui.trash.content.set_visible_child_name("list");
ui.trash.subtitle.set_subtitle(&subtitle);
// Only the rows that changed are swapped, so a refresh keeps the
// selection and the scroll position.
replace_items(&ui.trash.files.model, &sorted);
replace_items(&ui.trash.files.model, &rows);
sync_trash_selection(ui);
}
/// One row per folder things were deleted from, the most recent first. Items
/// trashed inside a trashed folder are found by opening that folder.
fn trash_locations(all: &[DirEntry]) -> Vec<DirEntry> {
let mut rows: Vec<DirEntry> = Vec::new();
let mut index: HashMap<Option<String>, usize> = HashMap::new();
for entry in all.iter().filter(|e| e.trashed_parent.is_none()) {
let key = entry.trashed_from.clone();
let at = *index.entry(key.clone()).or_insert_with(|| {
rows.push(location_row(key));
rows.len() - 1
});
let row = &mut rows[at];
row.size += 1;
row.trashed_at = row.trashed_at.max(entry.trashed_at);
row.modified = row.modified.max(entry.modified);
}
sort_trash(&mut rows);
rows
}
/// The row that stands for the folder `key`, still holding nothing.
fn location_row(key: Option<String>) -> DirEntry {
let (uid, name) = match key.as_deref() {
None => (
format!("{LOCATION_UID}{UNKNOWN_LOCATION}"),
gettext("Unknown folder"),
),
Some("") => (LOCATION_UID.to_string(), gettext("My files")),
Some(path) => (
format!("{LOCATION_UID}{path}"),
path.rsplit('/').next().unwrap_or(path).to_string(),
),
};
DirEntry {
name,
is_dir: true,
size: 0,
modified: 0,
pinned: false,
pinned_by_folder: false,
cached: false,
uid,
path: String::new(),
role: String::new(),
shared_by: String::new(),
shared_at: 0,
shared_by_unverified: false,
trashed_at: 0,
trashed_from: key,
trashed_parent: None,
issue: None,
}
}
/// The folder a location row stands for, or `None` for any other row.
fn location_key(uid: &str) -> Option<Option<String>> {
let key = uid.strip_prefix(LOCATION_UID)?;
Some((key != UNKNOWN_LOCATION).then(|| key.to_string()))
}
/// Whether the stored listing holds `uid`, so it can be restored on its own.
fn in_trash(ui: &Ui, uid: &str) -> bool {
ui.trash.all.borrow().iter().any(|e| e.uid == uid)
}
/// The trashed folder the user opened from a location, when inside one.
fn outer_folder(ui: &Ui) -> Option<DirEntry> {
let nav = ui.trash.nav.borrow();
let uid = nav.iter().find_map(|step| match step {
TrashNav::Folder { uid, .. } => Some(uid.clone()),
TrashNav::Location { .. } => None,
})?;
ui.trash.all.borrow().iter().find(|e| e.uid == uid).cloned()
}
/// What acting on `entries` acts on: a location row stands for everything
/// deleted from that folder, and an item that went with its folder for the
/// folder. Each node once.
fn trashed_targets(ui: &Ui, entries: &[DirEntry]) -> Vec<DirEntry> {
let all = ui.trash.all.borrow();
let outer = outer_folder(ui);
let mut seen = HashSet::new();
let mut targets = Vec::new();
for entry in entries {
let picked: Vec<DirEntry> = if let Some(key) = location_key(&entry.uid) {
all.iter()
.filter(|e| e.trashed_parent.is_none() && e.trashed_from == key)
.cloned()
.collect()
} else if all.iter().any(|e| e.uid == entry.uid) {
vec![entry.clone()]
} else {
outer.clone().into_iter().collect()
};
for target in picked {
if seen.insert(target.uid.clone()) {
targets.push(target);
}
}
}
targets
}
/// Rebuild the path bar for `nav`: "Trash", then each place down to the
/// current one. Hidden at the top, where there is nowhere to go back to.
fn repaint_trash_crumb(ui: &Rc<Ui>) {
let nav = ui.trash.nav.borrow();
let crumb = &ui.trash.crumb;
while let Some(child) = crumb.first_child() {
crumb.remove(&child);
}
ui.trash.back.set_visible(!nav.is_empty());
crumb.append(&trash_crumb_node(ui, &gettext("Trash"), 0, nav.is_empty()));
for (i, step) in nav.iter().enumerate() {
let label = match step {
TrashNav::Location { label, .. } => label,
TrashNav::Folder { name, .. } => name,
};
crumb.append(&crumb_separator());
crumb.append(&trash_crumb_node(ui, label, i + 1, i + 1 == nav.len()));
}
}
fn trash_crumb_node(ui: &Rc<Ui>, label: &str, depth: usize, current: bool) -> gtk4::Widget {
if current {
return crumb_current(label);
}
let button = gtk4::Button::builder().label(label).build();
button.add_css_class("flat");
let ui = ui.clone();
button.connect_clicked(move |_| {
ui.trash.nav.borrow_mut().truncate(depth);
show_trash_place(&ui);
});
button.upcast()
}
/// Newest deletion first. Entries with no known deletion time go last, newest
/// modification first among themselves.
fn sort_trash(entries: &mut [DirEntry]) {
@@ -393,6 +810,10 @@ fn clear_trash(ui: &Rc<Ui>) {
/// Restore trashed entries to the folders they were trashed from. When they
/// all came from one known folder, the toast offers to show it.
pub(crate) fn restore_entries(ui: &Rc<Ui>, entries: &[DirEntry]) {
let entries = &trashed_targets(ui, entries)[..];
if entries.is_empty() {
return;
}
let message = match entries {
// Translators: {name} is a file or folder name.
[one] => gettext_f("Restored “{name}”", &[("name", &one.name)]),
@@ -430,6 +851,10 @@ fn common_origin(entries: &[DirEntry]) -> Option<String> {
/// Confirm, then permanently delete trashed entries. Irreversible, so it asks.
pub(crate) fn prompt_delete_forever(ui: &Rc<Ui>, entries: &[DirEntry]) {
let entries = &trashed_targets(ui, entries)[..];
if entries.is_empty() {
return;
}
let win = ui_window(ui);
let uids: Vec<String> = entries.iter().map(|e| e.uid.clone()).collect();
let count = entries.len() as u64;
@@ -485,7 +910,7 @@ pub(crate) fn prompt_delete_forever(ui: &Rc<Ui>, entries: &[DirEntry]) {
/// Confirm, then permanently delete everything in the trash.
pub(crate) fn prompt_empty_trash(ui: &Rc<Ui>) {
let win = ui_window(ui);
let count = ui.trash.files.model.n_items();
let count = ui.trash.all.borrow().len();
let dialog = adw::AlertDialog::builder()
.heading(gettext("Empty Trash?"))
.body(ngettext_f(
@@ -536,10 +961,64 @@ mod tests {
shared_by_unverified: false,
trashed_at,
trashed_from: from.map(str::to_string),
trashed_parent: None,
issue: None,
}
}
fn inside(name: &str, parent: &str) -> DirEntry {
DirEntry {
trashed_parent: Some(parent.into()),
..trashed(name, 5, 1, None)
}
}
#[test]
fn locations_group_top_level_items_by_folder() {
let all = vec![
trashed("a", 30, 1, Some("Photos/2019")),
trashed("b", 10, 1, Some("Photos/2019")),
trashed("c", 20, 1, Some("")),
trashed("d", 5, 1, None),
inside("e", "a"),
];
let rows = trash_locations(&all);
let summary: Vec<(&str, u64, i64)> = rows
.iter()
.map(|r| (r.name.as_str(), r.size, r.trashed_at))
.collect();
assert_eq!(
summary,
[
("2019", 2, 30),
("My files", 1, 20),
("Unknown folder", 1, 5)
]
);
assert_eq!(location_key(&rows[0].uid), Some(Some("Photos/2019".into())));
assert_eq!(location_key(&rows[1].uid), Some(Some(String::new())));
assert_eq!(location_key(&rows[2].uid), Some(None));
assert_eq!(location_key("vol~link"), None);
}
#[test]
fn a_place_stays_only_while_the_listing_still_leads_there() {
let all = vec![trashed("album", 1, 1, Some("Photos")), inside("x", "album")];
let location = TrashNav::Location {
key: Some("Photos".into()),
label: "Photos".into(),
};
let folder = |uid: &str| TrashNav::Folder {
uid: uid.into(),
name: uid.into(),
};
// Folders below the trashed one are not listed themselves.
let nav = [location.clone(), folder("album"), folder("child")];
assert_eq!(kept_steps(&nav, &all), 3);
assert_eq!(kept_steps(&[location.clone(), folder("gone")], &all), 1);
assert_eq!(kept_steps(&nav, &[]), 0);
}
#[test]
fn trash_lists_newest_deletion_first_and_undated_last() {
let mut entries = vec![