Skip to content

Commit

Permalink
do not create duplicate FileData entries
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Jul 22, 2008
1 parent 96293a9 commit d576f7b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/filedata.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ static void file_data_set_path(FileData *fd, const gchar *path)
g_hash_table_remove(file_data_pool, fd->original_path);
g_free(fd->original_path);
}

g_assert(!g_hash_table_lookup(file_data_pool, path));

fd->original_path = g_strdup(path);
g_hash_table_insert(file_data_pool, fd->original_path, fd);

Expand Down Expand Up @@ -1758,7 +1761,20 @@ static void file_data_apply_ci(FileData *fd)
{
DEBUG_1("planned change: applying %s -> %s", fd->change->dest, fd->path);
file_data_planned_change_remove(fd);
file_data_set_path(fd, fd->change->dest);

if (g_hash_table_lookup(file_data_pool, fd->change->dest))
{
/* this change overwrites another file which is already known to other modules
renaming fd would create duplicate FileData structure
the best thing we can do is nothing
FIXME: maybe we could copy stuff like marks
*/
DEBUG_1("can't rename fd, target exists %s -> %s", fd->change->dest, fd->path);
}
else
{
file_data_set_path(fd, fd->change->dest);
}
}
file_data_increment_version(fd);
file_data_send_notification(fd, NOTIFY_TYPE_CHANGE);
Expand Down

0 comments on commit d576f7b

Please sign in to comment.