From 04acae61b02151f00c85493f65d48eb34d17e429 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 28 Jun 2023 10:37:35 +0100 Subject: [PATCH] Do not delay adding file to model --- libcore/Directory.vala | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/libcore/Directory.vala b/libcore/Directory.vala index ce8d8b4a5..717202f04 100644 --- a/libcore/Directory.vala +++ b/libcore/Directory.vala @@ -912,28 +912,28 @@ public class Files.Directory : Object { } } - private void add_and_refresh (Files.File gof, bool is_internal) { - // 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 (); - } - + private void notify_file_added (Files.File gof, bool is_internal) { + // Do not delay adding file to model - use fallback is_hidden + gof.is_hidden = gof.basename.has_prefix (".") || gof.basename.has_prefix ("~"); if ((!gof.is_hidden || Preferences.get_default ().show_hidden_files)) { file_added (gof, is_internal); } - if (!gof.is_hidden && gof.is_folder ()) { - /* add to sorted_dirs */ - if (sorted_dirs.find (gof) == null) { - sorted_dirs.insert_sorted (gof, - Files.File.compare_by_display_name); + query_info_async.begin (gof, null, (obj, res) => { + if (gof.info == null) { + critical ("%s FILE INFO unavailable", gof.basename); + } else { + // Update properties from FileInfo + gof.update (); + if (!gof.is_hidden && gof.is_folder ()) { + /* add to sorted_dirs */ + if (sorted_dirs.find (gof) == null) { + sorted_dirs.insert_sorted (gof, + Files.File.compare_by_display_name); + } + } } - } + }); } private void notify_file_changed (Files.File gof) { @@ -942,12 +942,6 @@ public class Files.Directory : Object { }); } - private void notify_file_added (Files.File gof, bool is_internal) { - query_info_async.begin (gof, null, () => { - add_and_refresh (gof, is_internal); - }); - } - private void notify_file_removed (Files.File gof) { this.file_hash.remove (gof.location);