From 61fb31ffacd06526c42f109227e1f9aa38ea498c Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Mon, 22 May 2023 09:19:13 +0100 Subject: [PATCH] Do not show externally created hidden files with no file info (#2200) Co-authored-by: Ryan Kornheisl --- libcore/Directory.vala | 12 ++++++++---- libcore/File.vala | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/libcore/Directory.vala b/libcore/Directory.vala index ead29eadf..18673fd16 100644 --- a/libcore/Directory.vala +++ b/libcore/Directory.vala @@ -910,12 +910,16 @@ public class Files.Directory : Object { } private void add_and_refresh (Files.File gof, bool is_internal) { - if (gof.info == null) { - critical ("FILE INFO null"); + // Check whether we have FileInfo + if (!gof.ensure_query_info ()) { + critical ("FILE INFO unavailable"); + // Fallback to determining hidden status from file name + gof.is_hidden = gof.basename.has_prefix (".") || gof.basename.has_prefix ("~"); + } else { + // Update properties from FileInfo + gof.update (); } - gof.update (); - if ((!gof.is_hidden || Preferences.get_default ().show_hidden_files)) { file_added (gof, is_internal); } diff --git a/libcore/File.vala b/libcore/File.vala index c53dbcf4a..5aa7a17a5 100644 --- a/libcore/File.vala +++ b/libcore/File.vala @@ -440,7 +440,9 @@ public class Files.File : GLib.Object { } public void update () { - GLib.return_if_fail (info != null); + if (info == null) { + return; + } /* free previously allocated */ clear_info ();