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.

Plain folders no longer take the icon of a folder's desktop.ini that Windows ignores (917)

denfry7a0f9cdf2805
diff --git a/crates/rf-win/src/thumbs.rs b/crates/rf-win/src/thumbs.rs
index c7f29657..b537261e 100644
--- a/crates/rf-win/src/thumbs.rs
+++ b/crates/rf-win/src/thumbs.rs
@@ -154,8 +154,11 @@ pub fn get_image(path: &Path, size: u32, kind: Kind) -> anyhow::Result<Bgra> {
}
// A customised folder's icon straight from the file its desktop.ini names. The shell keeps a folder's desktop.ini in this
// process: asked again after the icon was changed a second time, it gave the first icon back (issue 65). A file that gives no
- // picture leaves it to the shell, as before.
+ // picture leaves it to the shell, as before. Only a folder the shell itself would read it for: a plain folder's picture fills the
+ // one slot every plain folder shares, and a NAS's `#recycle` with the Recycle Bin in its desktop.ini gave all of them that icon
+ // (issue 917).
if matches!(kind, Kind::Icon)
+ && std::fs::metadata(path).is_ok_and(|m| folder_has_own_icon(std::os::windows::fs::MetadataExt::file_attributes(&m)))
&& let Some((file, index)) = crate::folder_custom::folder_icon(path)
{
let file = std::path::PathBuf::from(crate::folder_custom::expand_env(&file));
@@ -790,6 +793,21 @@ mod tests {
assert!(i_plain.data != i_own.data, "the customised folder's picture is the plain folder's");
}
+ /// A desktop.ini in a folder that is neither read-only nor a system folder is not read, as the shell does not read it: the
+ /// folder is drawn as a plain one (issue 917, a Synology share's `#recycle` naming the Recycle Bin icon).
+ #[test]
+ fn an_unmarked_folder_with_a_desktop_ini_is_drawn_plain() {
+ let base = std::env::temp_dir().join(format!("rf-foldericon-unmarked-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&base);
+ let (plain, recycle) = (base.join("plain"), base.join("#recycle"));
+ std::fs::create_dir_all(&plain).unwrap();
+ std::fs::create_dir_all(&recycle).unwrap();
+ std::fs::write(recycle.join("desktop.ini"), "[.ShellClassInfo]\r\nIconFile=%SystemRoot%\\system32\\SHELL32.dll\r\nIconIndex=32\r\n").unwrap();
+ let (i_plain, i_recycle) = (get_image(&plain, 32, Kind::Icon).unwrap(), get_image(&recycle, 32, Kind::Icon).unwrap());
+ let _ = std::fs::remove_dir_all(&base);
+ assert!(i_plain.data == i_recycle.data, "an unmarked folder took the icon its desktop.ini names");
+ }
+
#[test]
fn icon_for_exe_and_folder() {
let exe = PathBuf::from(r"C:\Windows\explorer.exe");