file-roller r2228 - in trunk: . src



Author: paobac
Date: Fri Apr 11 11:20:53 2008
New Revision: 2228
URL: http://svn.gnome.org/viewvc/file-roller?rev=2228&view=rev

Log:
2008-04-11  Paolo Bacchilega  <paobac svn gnome org>

	* src/gio-utils.c: close the enumerator when done
	* src/fr-archive.c: check for file existence before tryinh to load the
	archive.
	* src/file-utils.c (check_permissions): there is no need to add the uri
	in the warning because it's already included in the gerror message.


Modified:
   trunk/ChangeLog
   trunk/src/file-utils.c
   trunk/src/fr-archive.c
   trunk/src/gio-utils.c

Modified: trunk/src/file-utils.c
==============================================================================
--- trunk/src/file-utils.c	(original)
+++ trunk/src/file-utils.c	Fri Apr 11 11:20:53 2008
@@ -998,7 +998,7 @@
 	file = g_file_new_for_uri (uri);
 	info = g_file_query_info (file, "access::*", 0, NULL, &err);
 	if (err != NULL) {
-		g_warning ("Failed to get access permissions for %s: %s", uri, err->message);
+		g_warning ("Failed to get access permissions: %s", err->message);
 		g_clear_error (&err);
 		result = FALSE;
 	}

Modified: trunk/src/fr-archive.c
==============================================================================
--- trunk/src/fr-archive.c	(original)
+++ trunk/src/fr-archive.c	Fri Apr 11 11:20:53 2008
@@ -1321,6 +1321,14 @@
 {
 	XferData *xfer_data;
 	
+	if (! g_file_query_exists (archive->file, NULL)) {
+		GError *error;
+		error = g_error_new (G_IO_ERROR, G_IO_ERROR_NOT_FOUND, _("The file doesn't exist"));
+		fr_archive_copy_done (archive, FR_ACTION_LOADING_ARCHIVE, error);
+		g_error_free (error);
+		return;
+	}
+	
 	xfer_data = g_new0 (XferData, 1);
 	xfer_data->archive = archive;
 	xfer_data->uri = g_file_get_uri (archive->file);

Modified: trunk/src/gio-utils.c
==============================================================================
--- trunk/src/gio-utils.c	(original)
+++ trunk/src/gio-utils.c	Fri Apr 11 11:20:53 2008
@@ -224,6 +224,10 @@
 	ForEachChildData *fec = user_data;
 	
 	g_source_remove (fec->source_id);
+	if (fec->current != NULL) {
+		g_object_unref (fec->current);
+		 fec->current = NULL;
+	}
 	if (fec->done_func) 
 		fec->done_func (fec->error, fec->user_data);
 	for_each_child_data_free (fec);
@@ -247,6 +251,47 @@
 }
 
 
+void
+for_each_child_close_enumerator (GObject      *source_object,
+	              		 GAsyncResult *result,
+		      		 gpointer      user_data)
+{
+	ForEachChildData *fec = user_data;
+	GError           *error;
+	
+	if (! g_file_enumerator_close_finish (fec->enumerator,
+					      result,
+					      &error)) 
+	{
+		if (fec->error == NULL)
+			fec->error = g_error_copy (error);
+		else
+			g_clear_error (&error);
+	}
+	
+	if ((fec->error == NULL) && fec->recursive) {
+		char *sub_directory = NULL;
+			
+		if (fec->to_visit != NULL) {
+			GList *tmp;
+				
+			sub_directory = (char*) fec->to_visit->data;
+			tmp = fec->to_visit;
+			fec->to_visit = g_list_remove_link (fec->to_visit, tmp);
+			g_list_free (tmp);
+		}
+			
+		if (sub_directory != NULL) {
+			for_each_child_set_current (fec, sub_directory);
+			fec->source_id = g_idle_add (for_each_child_start_cb, fec);
+			return;
+		}
+	}
+	
+	fec->source_id = g_idle_add (for_each_child_done_cb, fec);
+}
+
+
 static void  
 for_each_child_next_files_ready (GObject      *source_object,
 			         GAsyncResult *result,
@@ -259,27 +304,13 @@
 	children = g_file_enumerator_next_files_finish (fec->enumerator,
                                                         result,
                                                         &(fec->error));
-                                                        
+
 	if (children == NULL) {
-		if ((fec->error == NULL) && fec->recursive) {
-			char *sub_directory = NULL;
-			
-			if (fec->to_visit != NULL) {
-				GList *tmp;
-				
-				sub_directory = (char*) fec->to_visit->data;
-				tmp = fec->to_visit;
-				fec->to_visit = g_list_remove_link (fec->to_visit, tmp);
-				g_list_free (tmp);
-			}
-			
-			if (sub_directory != NULL) {
-				for_each_child_set_current (fec, sub_directory);
-				fec->source_id = g_idle_add (for_each_child_start_cb, fec);
-				return;
-			}
-		}
-		fec->source_id = g_idle_add (for_each_child_done_cb, fec);
+		g_file_enumerator_close_async (fec->enumerator,
+					       G_PRIORITY_DEFAULT,
+					       fec->cancellable,
+					       for_each_child_close_enumerator,
+					       fec);
 		return;
 	}
 	



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