changeset 912:9108a7158c02

remove items from file_data_planned_change_hash when the operation is canceled
author nadvornik
date Tue, 22 Jul 2008 18:13:41 +0000
parents 8adf248bf5c9
children 2f9edd196dca
files src/filedata.c
diffstat 1 files changed, 26 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/filedata.c	Tue Jul 22 17:57:22 2008 +0000
+++ b/src/filedata.c	Tue Jul 22 18:13:41 2008 +0000
@@ -1172,6 +1172,27 @@
 	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;
@@ -1179,6 +1200,8 @@
 	if (!fdci)
 		return;
 
+	file_data_planned_change_remove(fd);
+
 	g_free(fdci->source);
 	g_free(fdci->dest);
 
@@ -1656,7 +1679,7 @@
 /*
  * updates FileData structure according to FileDataChangeInfo
  */
- 
+
 static void file_data_apply_ci(FileData *fd)
 {
 	FileDataChangeType type = fd->change->type;
@@ -1664,22 +1687,8 @@
 	/* 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);