Skip to content

Commit

Permalink
remove items from file_data_planned_change_hash when the operation is
Browse files Browse the repository at this point in the history
canceled
  • Loading branch information
nadvornik committed Jul 22, 2008
1 parent 3a0d2bb commit c8d7bc4
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions src/filedata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1172,13 +1172,36 @@ gboolean file_data_add_ci(FileData *fd, FileDataChangeType type, const gchar *sr
return TRUE;
}

static void file_data_planned_change_remove(FileData *fd)
{
if (file_data_planned_change_hash &&
(fd->change->type == FILEDATA_CHANGE_MOVE || fd->change->type == FILEDATA_CHANGE_RENAME))
{
if (g_hash_table_lookup(file_data_planned_change_hash, fd->change->dest) == fd)
{
DEBUG_1("planned change: removing %s -> %s", fd->change->dest, fd->path);
g_hash_table_remove(file_data_planned_change_hash, fd->change->dest);
file_data_unref(fd);
if (g_hash_table_size(file_data_planned_change_hash) == 0)
{
g_hash_table_destroy(file_data_planned_change_hash);
file_data_planned_change_hash = NULL;
DEBUG_1("planned change: empty");
}
}
}
}


void file_data_free_ci(FileData *fd)
{
FileDataChangeInfo *fdci = fd->change;

if (!fdci)
return;

file_data_planned_change_remove(fd);

g_free(fdci->source);
g_free(fdci->dest);

Expand Down Expand Up @@ -1656,30 +1679,16 @@ gboolean file_data_sc_perform_ci(FileData *fd)
/*
* updates FileData structure according to FileDataChangeInfo
*/

static void file_data_apply_ci(FileData *fd)
{
FileDataChangeType type = fd->change->type;

/* FIXME delete ?*/
if (type == FILEDATA_CHANGE_MOVE || type == FILEDATA_CHANGE_RENAME)
{
if (file_data_planned_change_hash)
{
if (g_hash_table_lookup(file_data_planned_change_hash, fd->change->dest) == fd)
{
DEBUG_1("planned change: applying %s -> %s", fd->change->dest, fd->path);
g_hash_table_remove(file_data_planned_change_hash, fd->change->dest);
file_data_unref(fd);
if (g_hash_table_size(file_data_planned_change_hash) == 0)
{
g_hash_table_destroy(file_data_planned_change_hash);
file_data_planned_change_hash = NULL;
DEBUG_1("planned change: empty");
}
}
}

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);
}
file_data_increment_version(fd);
Expand Down

0 comments on commit c8d7bc4

Please sign in to comment.