gvfs r1207 - in trunk: . daemon



Author: tbzatek
Date: Tue Jan 29 16:38:02 2008
New Revision: 1207
URL: http://svn.gnome.org/viewvc/gvfs?rev=1207&view=rev

Log:
2008-01-29  Tomas Bzatek  <tbzatek redhat com> 

        * daemon/gvfsbackendlocaltest.c: 
        Fixed error handling in do_enumerate ()
        More cleanup



Modified:
   trunk/ChangeLog
   trunk/daemon/gvfsbackendlocaltest.c

Modified: trunk/daemon/gvfsbackendlocaltest.c
==============================================================================
--- trunk/daemon/gvfsbackendlocaltest.c	(original)
+++ trunk/daemon/gvfsbackendlocaltest.c	Tue Jan 29 16:38:02 2008
@@ -87,7 +87,7 @@
  */
 
 
-static void     
+static gboolean     
 inject_error (GVfsBackend *backend,
 			  GVfsJob *job,
 			  GVfsJobType job_type)
@@ -99,9 +99,11 @@
   {
 	  g_print ("(II) inject_error: BANG! injecting error... \n");
       g_vfs_job_failed (G_VFS_JOB (job),
-			G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+			G_IO_ERROR, G_IO_ERROR_FAILED,
 			"Injected error");
-  } else g_vfs_job_succeeded (job); 
+      return FALSE;
+  } else g_vfs_job_succeeded (job);
+  return TRUE;
 }
 
 
@@ -284,30 +286,37 @@
   GFileInfo *info;
   GError *error;
   GFileEnumerator *enumerator;
+  gboolean res;
   
   g_print ("(II) try_enumerate (filename = %s) \n", filename);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
+  res = TRUE;
 
   error = NULL;
   enumerator = g_file_enumerate_children (file, "*", flags, G_VFS_JOB (job)->cancellable, &error);
   if (enumerator) {
 	  error = NULL;
-      while ((info = g_file_enumerator_next_file (enumerator, G_VFS_JOB (job)->cancellable, &error)) != NULL) {
+	  while ((info = g_file_enumerator_next_file (enumerator, G_VFS_JOB (job)->cancellable, &error)) != NULL) {
     	  g_print ("  (II) try_enumerate (filename = %s): file '%s' \n", filename, g_file_info_get_attribute_string(info, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME));
     	  g_vfs_job_enumerate_add_info (job, info);
       }
 	  if (error) {
 		  g_print ("  (EE) try_enumerate: error: %s \n", error->message);
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
+		  g_error_free (error);
+		  res = FALSE;
 	  } else 
-		  inject_error (backend, G_VFS_JOB (job), GVFS_JOB_ENUMERATE);
+		  res = inject_error (backend, G_VFS_JOB (job), GVFS_JOB_ENUMERATE);
+	  
 	  error = NULL;
       g_file_enumerator_close (enumerator, G_VFS_JOB (job)->cancellable, &error);
 	  if (error) {
 		  g_print ("  (EE) try_enumerate: g_file_enumerator_close() error: %s \n", error->message);
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
+		  g_error_free (error);
+		  res = FALSE;
 	  } 
       g_object_unref (enumerator);
       g_print ("  (II) try_enumerate: success. \n");
@@ -315,15 +324,21 @@
 	  if (error) {
 		  g_print ("  (EE) try_enumerate: error: %s \n", error->message);
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
+		  g_error_free (error);
+		  res = FALSE;
 	  } else { 
 		  g_print ("  (EE) try_enumerate: error == NULL \n");
 		  g_vfs_job_failed (G_VFS_JOB (job),
 					G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
 					"Error try_enumerate");
+		  res = FALSE;
 	  }
   }
+
   g_object_unref (file);
-  g_vfs_job_enumerate_done (job);  
+  if (res) {
+	  g_vfs_job_enumerate_done (job);  
+  }
   
   g_print ("(II) try_enumerate done. \n");
 }
@@ -377,16 +392,17 @@
 	  if ((error) || (! info2) ) {
 		  g_print ("  (EE) try_query_fs_info (filename = '%s'): g_file_query_filesystem_info failed: %s \n", filename, error->message);
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
-	  } else
-	  {
+		  g_error_free (error);
+	  } else {
 	      g_file_info_copy_into (info2, info);
 	      g_object_unref (info2);
 	      g_object_unref (file);
 	      inject_error (backend, G_VFS_JOB (job), GVFS_JOB_QUERY_FS_INFO);
 	      g_print ("(II) try_query_fs_info success. \n");
 	  }
-  } else
+  } else {
 	  g_print ("(EE) try_query_fs_info failed. \n");
+  }
 }
 
 
@@ -402,7 +418,7 @@
   g_print ("(II) try_query_settable_attributes (filename = '%s') \n", filename);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
@@ -414,10 +430,12 @@
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_query_settable_attributes: g_file_query_settable_attributes == FALSE, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_query_settable_attributes: file == NULL \n");
+  }
 }
 
 static void
@@ -432,7 +450,7 @@
   g_print ("(II) try_query_writable_namespaces (filename = '%s') \n", filename);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
@@ -444,10 +462,12 @@
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_query_writable_namespaces: g_file_query_writable_namespaces == FALSE, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_query_writable_namespaces: file == NULL \n");
+  }
 }
 
 
@@ -470,7 +490,7 @@
   g_print ("(II) try_make_directory (filename = %s) \n", filename);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
@@ -480,10 +500,12 @@
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_make_directory: g_file_make_directory == FALSE \n");
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_make_directory: file == NULL \n");
+  }
 }
 
 
@@ -498,7 +520,7 @@
   g_print ("(II) try_delete (filename = %s) \n", filename);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
@@ -508,10 +530,12 @@
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_delete: g_file_delete == FALSE, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_delete: file == NULL \n");
+  }
 }
 
 
@@ -526,7 +550,7 @@
   g_print ("(II) try_trash (filename = %s) \n", filename);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
@@ -536,10 +560,12 @@
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_trash: g_file_trash == FALSE, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_trash: file == NULL \n");
+  }
 }
 
 
@@ -555,7 +581,7 @@
   g_print ("(II) try_make_symlink ('%s' --> '%s') \n", filename, symlink_value);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
@@ -565,10 +591,12 @@
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_make_symlink: g_file_make_symbolic_link == FALSE, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_make_symlink: file == NULL \n");
+  }
 }
 
 
@@ -588,7 +616,7 @@
 	  
   src_file = get_g_file_from_local (source, G_VFS_JOB (job));
   dst_file = get_g_file_from_local (destination, G_VFS_JOB (job));
-  g_assert(src_file != NULL);
+  g_assert (src_file != NULL);
 
   if (src_file) {
 	  error = NULL;
@@ -600,11 +628,13 @@
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_copy: g_file_copy == FALSE, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (src_file);
 	  g_object_unref (dst_file);
-  } else 
+  } else { 
 	  g_print ("  (EE) try_copy: file == NULL \n");
+  }
 }
 
 
@@ -624,7 +654,7 @@
 	  
   src_file = get_g_file_from_local (source, G_VFS_JOB (job));
   dst_file = get_g_file_from_local (destination, G_VFS_JOB (job));
-  g_assert(src_file != NULL);
+  g_assert (src_file != NULL);
 
   if (src_file) {
 	  error = NULL;
@@ -636,11 +666,13 @@
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_move: g_file_move == FALSE, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (src_file);
 	  g_object_unref (dst_file);
-  } else 
+  } else { 
 	  g_print ("  (EE) try_move: file == NULL \n");
+  }
 }
 
 
@@ -657,7 +689,7 @@
   g_print ("(II) try_set_display_name '%s' --> '%s' \n", filename, display_name);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
@@ -678,10 +710,12 @@
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_set_display_name: g_file_set_display_name == FALSE, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_set_display_name: file == NULL \n");
+  }
 }
 
 
@@ -700,7 +734,7 @@
   g_print ("(II) try_set_attribute (filename = '%s', attribute = '%s') \n", filename, attribute);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (set_attribute));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
@@ -710,10 +744,12 @@
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (set_attribute), error); 
 		  g_print ("  (EE) try_set_attribute: g_file_set_attribute == FALSE, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_set_attribute: file == NULL \n");
+  }
 }
 
 
@@ -727,7 +763,7 @@
  * 
  */
 
-//  MonitorProxy has been stolen from gvfsbackendtrash
+/*  MonitorProxy has been stolen from gvfsbackendtrash  */
 typedef struct {
   GVfsMonitor *vfs_monitor;
   GObject *monitor;
@@ -783,14 +819,18 @@
 {
   GObject *monitor;
   MonitorProxy *proxy;
-  GFile *file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  GFile *file;
+  
+  file = get_g_file_from_local (filename, G_VFS_JOB (job));
+  g_assert (file != NULL);
   
-  if (is_dir_monitor) monitor = G_OBJECT(g_file_monitor_directory (file, flags, G_VFS_JOB (job)->cancellable, NULL));
-  else monitor = G_OBJECT(g_file_monitor_file (file, flags, G_VFS_JOB (job)->cancellable, NULL));
+  if (is_dir_monitor) { 
+	  monitor = G_OBJECT (g_file_monitor_directory (file, flags, G_VFS_JOB (job)->cancellable, NULL));
+  } else {
+	  monitor = G_OBJECT (g_file_monitor_file (file, flags, G_VFS_JOB (job)->cancellable, NULL));
+  }
 	  
-  if (monitor)
-    {
+  if (monitor) {
       proxy = g_new0 (MonitorProxy, 1); 
       proxy->vfs_monitor = g_vfs_monitor_new (backend);
       proxy->monitor = monitor;
@@ -806,8 +846,7 @@
       inject_error (backend, G_VFS_JOB (job), GVFS_JOB_CREATE_DIR_MONITOR);
       g_print ("(II) create_dir_file_monitor success. \n");
     }
-  else
-    {
+  else  {
       g_print ("  (EE) create_dir_file_monitor: monitor == NULL \n");
       g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR,
                         G_IO_ERROR_NOT_SUPPORTED,
@@ -860,23 +899,25 @@
   g_print ("(II) try_open_for_read (filename = '%s') \n", filename);
   
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
 	  stream = g_file_read (file, G_VFS_JOB (job)->cancellable, &error);
 	  if (stream) {
-	    g_vfs_job_open_for_read_set_can_seek (job, g_seekable_can_seek (G_SEEKABLE (stream)));
-	      g_vfs_job_open_for_read_set_handle (job, stream);
+		  g_vfs_job_open_for_read_set_can_seek (job, g_seekable_can_seek (G_SEEKABLE (stream)));
+		  g_vfs_job_open_for_read_set_handle (job, stream);
 		  inject_error (backend, G_VFS_JOB (job), GVFS_JOB_OPEN_FOR_READ);
 		  g_print ("(II) try_open_for_read success. \n");
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_open_for_read: stream == NULL, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_open_for_read: file == NULL \n");
+  }
 }
 
 
@@ -894,10 +935,11 @@
   g_print ("(II) try_read (handle = '%lx', buffer = '%lx', bytes_requested = %ld) \n", 
 		  (long int)_handle, (long int)buffer, (long int)bytes_requested);
 
-  g_assert(stream != NULL);
+  g_assert (stream != NULL);
   
   error = NULL;
-  s = g_input_stream_read (G_INPUT_STREAM(stream), buffer, bytes_requested, G_VFS_JOB (job)->cancellable, &error); 
+  s = g_input_stream_read (G_INPUT_STREAM (stream), buffer, bytes_requested, 
+		  				   G_VFS_JOB (job)->cancellable, &error); 
   if (s >= 0) {
       g_vfs_job_read_set_size (job, s);
 	  inject_error (backend, G_VFS_JOB (job), GVFS_JOB_READ);
@@ -905,6 +947,7 @@
   } else  {
 	  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 	  g_print ("  (EE) try_read: g_input_stream_read() failed, error: %s \n", error->message);
+	  g_error_free (error);
   }
 }
 
@@ -921,16 +964,17 @@
 
   g_print ("(II) try_seek_on_read (handle = '%lx', offset = %ld) \n", (long int)_handle, (long int)offset);
 
-  g_assert(stream != NULL);
+  g_assert (stream != NULL);
   
   error = NULL;
   if (g_seekable_seek (G_SEEKABLE (stream), offset, type, G_VFS_JOB (job)->cancellable, &error)) {
-    g_vfs_job_seek_read_set_offset (job, g_seekable_tell (G_SEEKABLE (stream)));
+	  g_vfs_job_seek_read_set_offset (job, g_seekable_tell (G_SEEKABLE (stream)));
 	  inject_error (backend, G_VFS_JOB (job), GVFS_JOB_SEEK_ON_READ);
 	  g_print ("(II) try_seek_on_read success. \n");
   } else  {
 	  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 	  g_print ("  (EE) try_seek_on_read: g_file_input_stream_seek() failed, error: %s \n", error->message);
+	  g_error_free (error);
   }
 }
 
@@ -945,16 +989,17 @@
 
   g_print ("(II) try_close_read (handle = '%lx') \n", (long int)_handle);
 
-  g_assert(stream != NULL);
+  g_assert (stream != NULL);
   
   error = NULL;
-  if (g_input_stream_close (G_INPUT_STREAM(stream), G_VFS_JOB (job)->cancellable, &error)) {
+  if (g_input_stream_close (G_INPUT_STREAM (stream), G_VFS_JOB (job)->cancellable, &error)) {
 	  g_object_unref (stream);
 	  inject_error (backend, G_VFS_JOB (job), GVFS_JOB_CLOSE_READ);
 	  g_print ("(II) try_close_read success. \n");
   } else  {
 	  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 	  g_print ("  (EE) try_close_read: g_input_stream_close() failed, error: %s \n", error->message);
+	  g_error_free (error);
   }
 }
 
@@ -972,30 +1017,33 @@
   g_print ("(II) try_append_to (filename = %s) \n", filename);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
 	  stream = g_file_append_to (file, flags, G_VFS_JOB (job)->cancellable, &error);
 	  if (stream) {
-		  //  Should seek at the end of the file here
-	    if ((g_seekable_seek (G_SEEKABLE (stream), 0, G_SEEK_END, G_VFS_JOB (job)->cancellable, &error)) && (! error))
-	      g_vfs_job_open_for_write_set_initial_offset (job, g_seekable_tell (G_SEEKABLE (stream)));
-		  else
-			  g_print ("  (EE) try_append_to: error during g_file_output_stream_seek(), error: %s \n", error->message);
+		  /*  Should seek at the end of the file here  */
+		  if ((g_seekable_seek (G_SEEKABLE (stream), 0, G_SEEK_END, G_VFS_JOB (job)->cancellable, &error)) && (! error)) {
+			  g_vfs_job_open_for_write_set_initial_offset (job, g_seekable_tell (G_SEEKABLE (stream)));
+		  } else {
+		  	  g_print ("  (EE) try_append_to: error during g_file_output_stream_seek(), error: %s \n", error->message);
+		  }
 
-	    g_vfs_job_open_for_write_set_can_seek (job, g_seekable_can_seek (G_SEEKABLE (stream)));
-	      g_vfs_job_open_for_write_set_handle (job, stream);
+		  g_vfs_job_open_for_write_set_can_seek (job, g_seekable_can_seek (G_SEEKABLE (stream)));
+		  g_vfs_job_open_for_write_set_handle (job, stream);
 		  inject_error (backend, G_VFS_JOB (job), GVFS_JOB_APPEND_TO);
 
-	      g_print ("(II) try_append_to success. \n");
+		  g_print ("(II) try_append_to success. \n");
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_append_to: stream == NULL, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_append_to: file == NULL \n");
+  }
 }
 
 
@@ -1012,23 +1060,25 @@
   g_print ("(II) try_create (filename = %s) \n", filename);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
 	  stream = g_file_create (file, flags, G_VFS_JOB (job)->cancellable, &error);
 	  if (stream) {
-	    g_vfs_job_open_for_write_set_can_seek (job, g_seekable_can_seek (G_SEEKABLE (stream)));
-	      g_vfs_job_open_for_write_set_handle (job, stream);
+		  g_vfs_job_open_for_write_set_can_seek (job, g_seekable_can_seek (G_SEEKABLE (stream)));
+		  g_vfs_job_open_for_write_set_handle (job, stream);
 		  inject_error (backend, G_VFS_JOB (job), GVFS_JOB_CREATE);
 		  g_print ("(II) try_create success. \n");
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_create: stream == NULL, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_create: file == NULL \n");
+  }
 }
 
 
@@ -1047,23 +1097,25 @@
   g_print ("(II) try_replace (filename = '%s', etag = '%s') \n", filename, etag);
 
   file = get_g_file_from_local (filename, G_VFS_JOB (job));
-  g_assert(file != NULL);
+  g_assert (file != NULL);
 
   if (file) {
 	  error = NULL;
 	  stream = g_file_replace (file, etag, make_backup, flags, G_VFS_JOB (job)->cancellable, &error);
 	  if (stream) {
-	    g_vfs_job_open_for_write_set_can_seek (job, g_seekable_can_seek (G_SEEKABLE (stream)));
-	      g_vfs_job_open_for_write_set_handle (job, stream);
+		  g_vfs_job_open_for_write_set_can_seek (job, g_seekable_can_seek (G_SEEKABLE (stream)));
+		  g_vfs_job_open_for_write_set_handle (job, stream);
 		  inject_error (backend, G_VFS_JOB (job), GVFS_JOB_REPLACE);
 		  g_print ("(II) try_replace success. \n");
 	  } else {
 		  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 		  g_print ("  (EE) try_replace: stream == NULL, error: %s \n", error->message);
+		  g_error_free (error);
 	  }
 	  g_object_unref (file);
-  } else
+  } else {
 	  g_print ("  (EE) try_replace: file == NULL \n");
+  }
 }
 
 
@@ -1081,10 +1133,10 @@
   g_print ("(II) try_write (handle = '%lx', buffer = '%lx', buffer_size = %ld) \n", 
 		  (long int)_handle, (long int)buffer, (long int)buffer_size);
 
-  g_assert(stream != NULL);
+  g_assert (stream != NULL);
   
   error = NULL;
-  s = g_output_stream_write (G_OUTPUT_STREAM(stream), buffer, buffer_size, G_VFS_JOB (job)->cancellable, &error); 
+  s = g_output_stream_write (G_OUTPUT_STREAM (stream), buffer, buffer_size, G_VFS_JOB (job)->cancellable, &error); 
   if (s >= 0) {
 	  g_vfs_job_write_set_written_size (job, s);
 	  inject_error (backend, G_VFS_JOB (job), GVFS_JOB_WRITE);
@@ -1092,6 +1144,7 @@
   } else  {
 	  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 	  g_print ("  (EE) try_write: g_output_stream_write() failed, error: %s \n", error->message);
+	  g_error_free (error);
   }
 }
 
@@ -1108,16 +1161,17 @@
 
   g_print ("(II) try_seek_on_write (handle = '%lx', offset = %ld) \n", (long int)_handle, (long int)offset);
 
-  g_assert(stream != NULL);
+  g_assert (stream != NULL);
   
   error = NULL;
   if (g_seekable_seek (G_SEEKABLE (stream), offset, type, G_VFS_JOB (job)->cancellable, &error)) {
-    g_vfs_job_seek_write_set_offset (job, g_seekable_tell(G_SEEKABLE(stream)));
+	  g_vfs_job_seek_write_set_offset (job, g_seekable_tell (G_SEEKABLE (stream)));
 	  inject_error (backend, G_VFS_JOB (job), GVFS_JOB_SEEK_ON_WRITE);
 	  g_print ("(II) try_seek_on_write success. \n");
   } else  {
 	  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 	  g_print ("  (EE) try_seek_on_write: g_file_output_stream_seek() failed, error: %s \n", error->message);
+	  g_error_free (error);
   }
 }
 
@@ -1132,7 +1186,7 @@
 
   g_print ("(II) try_close_write (handle = '%lx') \n", (long int)_handle);
 
-  g_assert(stream != NULL);
+  g_assert (stream != NULL);
   
   error = NULL;
   if (g_output_stream_close (G_OUTPUT_STREAM(stream), G_VFS_JOB (job)->cancellable, &error)) {
@@ -1142,6 +1196,7 @@
   } else  {
 	  g_vfs_job_failed_from_error (G_VFS_JOB (job), error); 
 	  g_print ("  (EE) try_close_write: g_input_stream_close() failed, error: %s \n", error->message);
+	  g_error_free (error);
   }
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]