Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

The jump list keeps its tasks when Windows' recent items are turned off

denfry30d211bcbd00
diff --git a/crates/rf-win/src/jumplist.rs b/crates/rf-win/src/jumplist.rs
index 6425f95e..2a41f2b6 100644
--- a/crates/rf-win/src/jumplist.rs
+++ b/crates/rf-win/src/jumplist.rs
@@ -63,6 +63,14 @@ pub fn busy(hresult: u32) -> bool {
matches!(hresult, 0x8007_0497 | 0x8007_0498 | 0x8007_0499 | 0x8007_0020 | 0x8007_0021 | 0x8007_00B7)
}
+/// Whether `AppendCategory` refused the folders because of the user's privacy settings: with "Show recently opened items in
+/// Jump Lists" off (or the policy that turns it off) every custom category is refused with E_ACCESSDENIED, and Microsoft's
+/// documentation of `AppendCategory` says to go on with the tasks and commit. Before, that refusal ended the whole write, so those
+/// users got no jump list at all, not even "New window".
+pub fn categories_refused(hresult: u32) -> bool {
+ hresult == 0x8007_0005
+}
+
/// Replaces the jump list: tasks + categories of folders, in the order given (Windows shows
/// only as many items as the list has room for; the first category is filled first).
/// Writers take turns (see [`WRITING`]), and a write that found the list's file busy is tried again.
@@ -103,7 +111,12 @@ fn write(exe: &Path, tasks: &[(&str, &str)], categories: &[Category]) -> windows
}
room = room.saturating_sub(folders.len());
let wt = wide(cat_title);
- list.AppendCategory(PCWSTR(wt.as_ptr()), &coll.cast::<IObjectArray>()?)?;
+ match list.AppendCategory(PCWSTR(wt.as_ptr()), &coll.cast::<IObjectArray>()?) {
+ Ok(()) => {}
+ // (the next categories would be refused the same way: the tasks still go in)
+ Err(e) if categories_refused(e.code().0 as u32) => break,
+ Err(e) => return Err(e),
+ }
}
if !tasks.is_empty() {
let coll: IObjectCollection = CoCreateInstance(&EnumerableObjectCollection, None, CLSCTX_INPROC_SERVER)?;
@@ -129,6 +142,13 @@ mod tests {
super::set(&exe, &[("Yeni pencere", super::NEW_WINDOW_ARG)], &cats).unwrap();
}
+ #[test]
+ fn only_the_privacy_refusal_lets_the_tasks_go_on() {
+ assert!(super::categories_refused(0x8007_0005), "E_ACCESSDENIED: recent items are off");
+ assert!(!super::categories_refused(0x8004_0F03), "no file type registration: a real failure");
+ assert!(!super::categories_refused(0x8007_0497), "a busy file is tried again, not skipped");
+ }
+
fn one_category(i: usize) -> [super::Category; 1] {
[("Son klasörler".to_string(), vec![(format!("Klasör {i}"), std::env::temp_dir())])]
}