Index: modules/sftp-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/sftp-method.c,v
retrieving revision 1.45
diff -u -r1.45 sftp-method.c
--- modules/sftp-method.c	13 May 2006 15:51:58 -0000	1.45
+++ modules/sftp-method.c	18 Jun 2006 16:24:14 -0000
@@ -1832,8 +1832,20 @@
 
 		sftp_connection_unlock (conn);
 
-		DEBUG (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s: Exit", __FUNCTION__));
-		return GNOME_VFS_OK;
+		/* Before returning, check if given handle is really a file or a directory */
+		{
+			GnomeVFSFileInfo file_info;
+			GnomeVFSResult res;
+			res = do_get_file_info_from_handle(method, *method_handle, &file_info, GNOME_VFS_FILE_INFO_DEFAULT, context);
+			if (res == GNOME_VFS_OK && file_info.type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
+					DEBUG (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s: Exit", __FUNCTION__));
+					return GNOME_VFS_ERROR_IS_DIRECTORY;
+			}
+
+			DEBUG (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s: Exit", __FUNCTION__));
+			return res;
+		}
+
 	} else {
 		*method_handle = NULL;
 
