? modules/.ftp-method.c.swp
? modules/.sftp-method.c.swp
Index: modules/ftp-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/ftp-method.c,v
retrieving revision 1.115
diff -u -r1.115 ftp-method.c
--- modules/ftp-method.c	13 Apr 2005 19:58:55 -0000	1.115
+++ modules/ftp-method.c	30 Apr 2005 19:14:47 -0000
@@ -2581,6 +2581,18 @@
 			GNOME_VFS_ERROR_ACCESS_DENIED);
 		g_free(chmod_command);
 	}
+	else {
+		GnomeVFSResult tmp_result;
+		GnomeVFSFileInfo *file_info;
+
+		file_info = gnome_vfs_file_info_new ();
+		tmp_result = do_get_file_info (method, uri, file_info,
+					       GNOME_VFS_FILE_INFO_DEFAULT, context);
+		gnome_vfs_file_info_unref (file_info);
+
+		if (tmp_result == GNOME_VFS_OK)
+			result = GNOME_VFS_ERROR_FILE_EXISTS;
+	}
 
 	return result;
 }
Index: modules/sftp-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/sftp-method.c,v
retrieving revision 1.33
diff -u -r1.33 sftp-method.c
--- modules/sftp-method.c	13 Apr 2005 19:58:55 -0000	1.33
+++ modules/sftp-method.c	30 Apr 2005 19:14:49 -0000
@@ -2661,6 +2661,8 @@
 	guint id;
 	GnomeVFSFileInfo info;
 
+	DEBUG (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s: Enter", __FUNCTION__));
+
 	res = sftp_get_connection (&conn, uri);
 	if (res != GNOME_VFS_OK) return res;
 
@@ -2670,14 +2672,39 @@
 	if (path == NULL)
 		return GNOME_VFS_ERROR_INVALID_URI;
 
+	DEBUG (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s: Making %s", __FUNCTION__, path));
+
 	memset (&info, 0, sizeof (GnomeVFSFileInfo));
 	iobuf_send_string_request_with_file_info (conn->out_fd, id, SSH2_FXP_MKDIR,
 						  path, strlen (path), &info,
 						  GNOME_VFS_SET_FILE_INFO_NONE);
 
-	g_free (path);
-
 	res = iobuf_read_result (conn->in_fd, id);
+
+	if (res != SSH2_FX_OK) {
+		GnomeVFSResult newres;
+
+		id = sftp_connection_get_id (conn);
+
+		DEBUG (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s: Failed. Checking whether %s existed beforehand", __FUNCTION__, path));
+
+		iobuf_send_string_request (conn->out_fd, id,
+					   conn->version == 0 ? SSH2_FXP_STAT_VERSION_0 : SSH2_FXP_STAT,
+					   path, strlen (path));
+
+		newres = iobuf_read_file_info (conn->in_fd, &info, id);
+
+		if (newres == GNOME_VFS_OK) {
+			DEBUG (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s: Yes.": , __FUNCTION__, path));
+			res = GNOME_VFS_ERROR_FILE_EXISTS;
+		}
+		else
+			DEBUG (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s: No.": , __FUNCTION__, path));
+	}
+	else
+		DEBUG (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s: Succeeded.", __FUNCTION__));
+
+	g_free (path);
 
 	sftp_connection_unref (conn);
 	sftp_connection_unlock (conn);
