From 8e413ab3a64a5932290ae8ddb9c57999246cd1a8 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Sun, 9 Jul 2023 20:19:15 +0100 Subject: [PATCH] Fix regression adding folder to view --- libcore/Directory.vala | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libcore/Directory.vala b/libcore/Directory.vala index 717202f04..6ae5c754a 100644 --- a/libcore/Directory.vala +++ b/libcore/Directory.vala @@ -1074,19 +1074,20 @@ public class Files.Directory : Object { bool already_present = false; bool files_added = false; Directory? first_dir = cache_lookup_parent (changes.data.from); - GLib.File? prev_loc = null; if (first_dir != null) { foreach (unowned var change in changes) { - unowned var loc = change.from; - // Each set or changes should refer to the same folder but check anyway - if (prev_loc == null || !loc.equal (prev_loc)) { - Files.File gof = first_dir.file_cache_find_or_insert (loc, out already_present, true); + // `change.from`` holds the location of the newly created file, not where it came from + var dir = cache_lookup_parent (change.from); + // Children of newly created folder must have null parent Files.Directory + // We expect each set of changes to refer to the same Directory + if (dir != null && dir == first_dir) { + Files.File gof = first_dir.file_cache_find_or_insert (change.from, out already_present, true); if (!already_present) { files_added = true; first_dir.notify_file_added (gof, change.is_internal); } // Else ignore files already added from duplicate event or internally - - prev_loc = loc; + } else { + critical ("Unexpected parent of newly created file"); } }