aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-06-06 08:28:49 +0200
committerPřemysl Eric Janouch <p@janouch.name>2023-06-06 08:31:29 +0200
commit1c25cb411fc4eb9b1cbb11160560155667e30e81 (patch)
treef6c19dc87cbbe6967b3965bbaa0fda2f4dd98606
parent399c4bdf6980b463bc37f15dbeccbf64d2310f5c (diff)
downloadfiv-1c25cb411fc4eb9b1cbb11160560155667e30e81.tar.gz
fiv-1c25cb411fc4eb9b1cbb11160560155667e30e81.tar.xz
fiv-1c25cb411fc4eb9b1cbb11160560155667e30e81.zip
Fix the remaining case in file renames monitoring
-rw-r--r--fiv-io-model.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/fiv-io-model.c b/fiv-io-model.c
index 423e4fb..55ddd91 100644
--- a/fiv-io-model.c
+++ b/fiv-io-model.c
@@ -342,22 +342,21 @@ static void
monitor_apply(enum monitor_event event, GPtrArray *target, int index,
FivIoModelEntry *new_entry)
{
- // The file used to be filtered out but isn't anymore.
- // TODO(p): Handle the inverse transition as well.
if (event == MONITOR_RENAMING && index < 0)
+ // The file used to be filtered out but isn't anymore.
event = MONITOR_ADDING;
+ else if (!new_entry && index >= 0)
+ // The file wasn't filtered out but now it is.
+ event = MONITOR_REMOVING;
if (event == MONITOR_CHANGING) {
- g_assert(new_entry != NULL);
fiv_io_model_entry_unref(target->pdata[index]);
target->pdata[index] = fiv_io_model_entry_ref(new_entry);
}
if (event == MONITOR_REMOVING || event == MONITOR_RENAMING)
g_ptr_array_remove_index(target, index);
- if (event == MONITOR_RENAMING || event == MONITOR_ADDING) {
- g_assert(new_entry != NULL);
+ if (event == MONITOR_RENAMING || event == MONITOR_ADDING)
g_ptr_array_add(target, fiv_io_model_entry_ref(new_entry));
- }
}
static void
@@ -370,25 +369,25 @@ on_monitor_changed(G_GNUC_UNUSED GFileMonitor *monitor, GFile *file,
gint files_index = model_find(self->files, file, &old_entry);
gint subdirs_index = model_find(self->subdirs, file, &old_entry);
- enum monitor_event action = MONITOR_NONE;
+ enum monitor_event event = MONITOR_NONE;
GFile *new_entry_file = NULL;
switch (event_type) {
case G_FILE_MONITOR_EVENT_CHANGED:
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
- action = MONITOR_CHANGING;
+ event = MONITOR_CHANGING;
new_entry_file = file;
break;
case G_FILE_MONITOR_EVENT_RENAMED:
- action = MONITOR_RENAMING;
+ event = MONITOR_RENAMING;
new_entry_file = other_file;
break;
case G_FILE_MONITOR_EVENT_DELETED:
case G_FILE_MONITOR_EVENT_MOVED_OUT:
- action = MONITOR_REMOVING;
+ event = MONITOR_REMOVING;
break;
case G_FILE_MONITOR_EVENT_CREATED:
case G_FILE_MONITOR_EVENT_MOVED_IN:
- action = MONITOR_ADDING;
+ event = MONITOR_ADDING;
old_entry = NULL;
new_entry_file = file;
break;
@@ -432,12 +431,12 @@ run:
fiv_io_model_entry_ref(old_entry);
if (files_index != -1 || new_target == self->files) {
- monitor_apply(action, self->files, files_index, new_entry);
+ monitor_apply(event, self->files, files_index, new_entry);
g_signal_emit(self, model_signals[FILES_CHANGED],
0, old_entry, new_entry);
}
if (subdirs_index != -1 || new_target == self->subdirs) {
- monitor_apply(action, self->subdirs, subdirs_index, new_entry);
+ monitor_apply(event, self->subdirs, subdirs_index, new_entry);
g_signal_emit(self, model_signals[SUBDIRECTORIES_CHANGED],
0, old_entry, new_entry);
}