[file-roller] Do not copy remote files to a local folder, use gvfs directly.



commit 73fa5d77a60861cd35c6f3425d27c88061af081c
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Jul 13 22:05:28 2009 +0200

    Do not copy remote files to a local folder, use gvfs directly.

 src/actions.c        |    4 +-
 src/fr-archive.c     |  622 +++++---------------------------------------------
 src/fr-archive.h     |    2 -
 src/fr-command-tar.c |   23 ++-
 src/fr-command.c     |   16 +-
 src/fr-process.c     |   32 ++--
 src/fr-window.c      |   27 +--
 7 files changed, 127 insertions(+), 599 deletions(-)
---
diff --git a/src/actions.c b/src/actions.c
index 7507f39..a7ef8ff 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -359,11 +359,13 @@ open_file_response_cb (GtkWidget *w,
 	if ((window == NULL) || (uri == NULL))
 		return;
 
-	window = fr_window_archive_open (window, uri, GTK_WINDOW (file_sel));
+	if (fr_window_archive_is_present (window))
+		window = (FrWindow *) fr_window_new ();
 	g_signal_connect (G_OBJECT (window),
 			  "archive_loaded",
 			  G_CALLBACK (window_archive_loaded_cb),
 			  file_sel);
+	fr_window_archive_open (window, uri, GTK_WINDOW (file_sel));
 
 	g_free (uri);
 }
diff --git a/src/fr-archive.c b/src/fr-archive.c
index 27a8cd9..74d09ce 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -119,46 +119,11 @@ struct _FrArchivePrivData {
 	gboolean             continue_adding_dropped_items;
 	DroppedItemsData    *dropped_items_data;
 
-	char                *temp_extraction_dir;
 	char                *extraction_destination;
-	gboolean             remote_extraction;
 	gboolean             extract_here;
 };
 
 
-typedef struct {
-	FrArchive      *archive;
-	char           *uri;
-	FrAction        action;
-	GList          *file_list;
-	char           *base_uri;
-	char           *dest_dir;
-	gboolean        update;
-	char           *tmp_dir;
-	guint           source_id;
-	char           *password;
-	gboolean        encrypt_header;
-	FrCompression   compression;
-	guint           volume_size;
-} XferData;
-
-
-static void
-xfer_data_free (XferData *data)
-{
-	if (data == NULL)
-		return;
-
-	g_free (data->uri);
-	g_free (data->password);
-	path_list_free (data->file_list);
-	g_free (data->base_uri);
-	g_free (data->dest_dir);
-	g_free (data->tmp_dir);
-	g_free (data);
-}
-
-
 #define MAX_CHUNK_LEN (NCARGS * 2 / 3) /* Max command line length */
 #define UNKNOWN_TYPE "application/octet-stream"
 #define SAME_FS (FALSE)
@@ -357,8 +322,6 @@ static void
 fr_archive_init (FrArchive *archive)
 {
 	archive->file = NULL;
-	archive->local_copy = NULL;
-	archive->is_remote = FALSE;
 	archive->command = NULL;
 	archive->is_compressed_file = FALSE;
 	archive->can_create_compressed_file = FALSE;
@@ -370,7 +333,6 @@ fr_archive_init (FrArchive *archive)
 	archive->priv->add_is_stoppable_data = NULL;
 
 	archive->priv->extraction_destination = NULL;
-	archive->priv->temp_extraction_dir = NULL;
 	archive->priv->cancellable = g_cancellable_new ();
 
 	archive->process = fr_process_new ();
@@ -388,73 +350,18 @@ fr_archive_new (void)
 }
 
 
-static GFile *
-get_local_copy_for_file (GFile *remote_file)
-{
-	char  *temp_dir;
-	GFile *local_copy = NULL;
-
-	temp_dir = get_temp_work_dir (NULL);
-	if (temp_dir != NULL) {
-		char  *archive_name;
-		char  *local_path;
-
-		archive_name = g_file_get_basename (remote_file);
-		local_path = g_build_filename (temp_dir, archive_name, NULL);
-		local_copy = g_file_new_for_path (local_path);
-
-		g_free (local_path);
-		g_free (archive_name);
-	}
-	g_free (temp_dir);
-
-	return local_copy;
-}
-
-
 static void
 fr_archive_set_uri (FrArchive  *archive,
 		    const char *uri)
 {
-	if ((archive->local_copy != NULL) && archive->is_remote) {
-		GFile  *temp_folder;
-		GError *err = NULL;
-
-		g_file_delete (archive->local_copy, NULL, &err);
-		if (err != NULL) {
-			g_warning ("Failed to delete the local copy: %s", err->message);
-			g_clear_error (&err);
-		}
-
-		temp_folder = g_file_get_parent (archive->local_copy);
-		g_file_delete (temp_folder, NULL, &err);
-		if (err != NULL) {
-			g_warning ("Failed to delete temp folder: %s", err->message);
-			g_clear_error (&err);
-		}
-
-		g_object_unref (temp_folder);
-	}
-
 	if (archive->file != NULL) {
 		g_object_unref (archive->file);
 		archive->file = NULL;
 	}
-	if (archive->local_copy != NULL) {
-		g_object_unref (archive->local_copy);
-		archive->local_copy = NULL;
-	}
 	archive->content_type = NULL;
 
-	if (uri == NULL)
-		return;
-
-	archive->file = g_file_new_for_uri (uri);
-	archive->is_remote = ! g_file_has_uri_scheme (archive->file, "file");
-	if (archive->is_remote)
-		archive->local_copy = get_local_copy_for_file (archive->file);
-	else
-		archive->local_copy = g_file_dup (archive->file);
+	if (uri != NULL)
+		archive->file = g_file_new_for_uri (uri);
 }
 
 
@@ -488,7 +395,6 @@ fr_archive_finalize (GObject *object)
 		dropped_items_data_free (archive->priv->dropped_items_data);
 		archive->priv->dropped_items_data = NULL;
 	}
-	g_free (archive->priv->temp_extraction_dir);
 	g_free (archive->priv->extraction_destination);
 	g_free (archive->priv);
 
@@ -587,11 +493,11 @@ create_command_from_type (FrArchive     *archive,
 		          FrCommandCaps  requested_capabilities)
 {
 	char *filename;
-	
+
 	if (command_type == 0)
 		return FALSE;
 
-	filename = g_file_get_path (archive->local_copy);
+	filename = g_file_get_path (archive->file);
 	archive->command = FR_COMMAND (g_object_new (command_type,
 					             "process", archive->process,
 					             "filename", filename,
@@ -604,7 +510,7 @@ create_command_from_type (FrArchive     *archive,
 		archive->command = NULL;
 		archive->is_compressed_file = FALSE;
 	}
-	else 
+	else
 		archive->is_compressed_file = ! fr_command_is_capable_of (archive->command, FR_COMMAND_CAN_ARCHIVE_MANY_FILES);
 
 	return (archive->command != NULL);
@@ -633,11 +539,11 @@ create_command_to_load_archive (FrArchive  *archive,
 	if (command_type == 0) {
 		requested_capabilities ^= FR_COMMAND_CAN_WRITE;
 		command_type = get_command_type_from_mime_type (mime_type, requested_capabilities);
-	}	
+	}
 
 	return create_command_from_type (archive,
-					 mime_type, 
-					 command_type, 
+					 mime_type,
+					 command_type,
 					 requested_capabilities);
 }
 
@@ -656,8 +562,8 @@ create_command_to_create_archive (FrArchive  *archive,
 	command_type = get_command_type_from_mime_type (mime_type, requested_capabilities);
 
 	return create_command_from_type (archive,
-					 mime_type, 
-					 command_type, 
+					 mime_type,
+					 command_type,
 					 requested_capabilities);
 }
 
@@ -678,79 +584,6 @@ action_started (FrCommand *command,
 }
 
 
-/* -- copy_to_remote_location -- */
-
-
-static void
-fr_archive_copy_done (FrArchive *archive,
-		      FrAction   action,
-		      GError    *error)
-{
-	FrProcErrorType  error_type = FR_PROC_ERROR_NONE;
-	const char      *error_details = NULL;
-
-	if (error != NULL) {
-		error_type = (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) ? FR_PROC_ERROR_STOPPED : FR_PROC_ERROR_GENERIC);
-		error_details = error->message;
-	}
-	fr_archive_action_completed (archive, action, error_type, error_details);
-}
-
-
-static void
-copy_to_remote_location_done (GError   *error,
-			      gpointer  user_data)
-{
-	XferData *xfer_data = user_data;
-
-	fr_archive_copy_done (xfer_data->archive, xfer_data->action, error);
-	xfer_data_free (xfer_data);
-}
-
-
-static void
-copy_to_remote_location_progress (goffset   current_file,
-                                  goffset   total_files,
-                                  GFile    *source,
-                                  GFile    *destination,
-                                  goffset   current_num_bytes,
-                                  goffset   total_num_bytes,
-                                  gpointer  user_data)
-{
-	XferData *xfer_data = user_data;
-
-	g_signal_emit (G_OBJECT (xfer_data->archive),
-		       fr_archive_signals[PROGRESS],
-		       0,
-		       (double) current_num_bytes / total_num_bytes);
-}
-
-
-static void
-copy_to_remote_location (FrArchive  *archive,
-			 FrAction    action)
-{
-	XferData *xfer_data;
-
-	xfer_data = g_new0 (XferData, 1);
-	xfer_data->archive = archive;
-	xfer_data->action = action;
-
-	g_copy_file_async (archive->local_copy,
-			   archive->file,
-			   G_FILE_COPY_OVERWRITE,
-			   G_PRIORITY_DEFAULT,
-			   archive->priv->cancellable,
-			   copy_to_remote_location_progress,
-			   xfer_data,
-			   copy_to_remote_location_done,
-			   xfer_data);
-}
-
-
-/* -- copy_extracted_files_to_destination -- */
-
-
 static void
 move_here (FrArchive *archive)
 {
@@ -819,70 +652,6 @@ move_here (FrArchive *archive)
 }
 
 
-static void
-copy_extracted_files_done (GError   *error,
-			   gpointer  user_data)
-{
-	FrArchive *archive = user_data;
-
-	remove_local_directory (archive->priv->temp_extraction_dir);
-	g_free (archive->priv->temp_extraction_dir);
-	archive->priv->temp_extraction_dir = NULL;
-
-	fr_archive_action_completed (archive,
-				     FR_ACTION_COPYING_FILES_TO_REMOTE,
-				     FR_PROC_ERROR_NONE,
-				     NULL);
-
-	if ((error == NULL) && (archive->priv->extract_here))
-		move_here (archive);
-
-	fr_archive_copy_done (archive, FR_ACTION_EXTRACTING_FILES, error);
-}
-
-
-static void
-copy_extracted_files_progress (goffset   current_file,
-                               goffset   total_files,
-                               GFile    *source,
-                               GFile    *destination,
-                               goffset   current_num_bytes,
-                               goffset   total_num_bytes,
-                               gpointer  user_data)
-{
-	FrArchive *archive = user_data;
-
-	g_signal_emit (G_OBJECT (archive),
-		       fr_archive_signals[PROGRESS],
-		       0,
-		       (double) current_file / (total_files + 1));
-}
-
-
-static void
-copy_extracted_files_to_destination (FrArchive *archive)
-{
-	char *temp_extraction_dir;
-	char *extraction_destination;
-
-	temp_extraction_dir = g_filename_to_uri (archive->priv->temp_extraction_dir, NULL, NULL);
-	extraction_destination = g_filename_to_uri (archive->priv->extraction_destination, NULL, NULL);
-	
-	g_directory_copy_async (temp_extraction_dir,
-				extraction_destination,
-				G_FILE_COPY_OVERWRITE,
-				G_PRIORITY_DEFAULT,
-				archive->priv->cancellable,
-				copy_extracted_files_progress,
-				archive,
-				copy_extracted_files_done,
-				archive);
-	
-	g_free (extraction_destination);
-	g_free (temp_extraction_dir);
-}
-
-
 static void add_dropped_items (DroppedItemsData *data);
 
 
@@ -893,18 +662,12 @@ fr_archive_change_name (FrArchive  *archive,
 	const char *name;
 	GFile      *parent;
 
-
 	name = file_name_from_path (filename);
 
 	parent = g_file_get_parent (archive->file);
 	g_object_unref (archive->file);
 	archive->file = g_file_get_child (parent, name);
 	g_object_unref (parent);
-
-	parent = g_file_get_parent (archive->local_copy);
-	g_object_unref (archive->local_copy);
-	archive->local_copy = g_file_get_child (parent, name);
-	g_object_unref (parent);
 }
 
 
@@ -919,15 +682,6 @@ action_performed (FrCommand   *command,
 #endif
 
 	switch (action) {
-	case FR_ACTION_DELETING_FILES:
-		if (error->type == FR_PROC_ERROR_NONE) {
-			if (! g_file_has_uri_scheme (archive->file, "file")) {
-				copy_to_remote_location (archive, action);
-				return;
-			}
-		}
-		break;
-
 	case FR_ACTION_ADDING_FILES:
 		if (error->type == FR_PROC_ERROR_NONE) {
 			fr_archive_remove_temp_work_dir (archive);
@@ -943,32 +697,15 @@ action_performed (FrCommand   *command,
 			 * original name */
 			if (archive->command->multi_volume)
 				fr_archive_change_name (archive, archive->command->filename);
-			if (! g_file_has_uri_scheme (archive->file, "file")) {
-				copy_to_remote_location (archive, action);
-				return;
-			}
 		}
 		break;
 
 	case FR_ACTION_EXTRACTING_FILES:
 		if (error->type == FR_PROC_ERROR_NONE) {
-			if  (archive->priv->remote_extraction) {
-				copy_extracted_files_to_destination (archive);
-				return;
-			}
-			else if (archive->priv->extract_here)
+			if (archive->priv->extract_here)
 				move_here (archive);
 		}
 		else {
-			/* if an error occurred during extraction remove the
-			 * temp extraction dir, if used. */
-
-			if ((archive->priv->remote_extraction) && (archive->priv->temp_extraction_dir != NULL)) {
-				remove_local_directory (archive->priv->temp_extraction_dir);
-				g_free (archive->priv->temp_extraction_dir);
-				archive->priv->temp_extraction_dir = NULL;
-			}
-
 			if (archive->priv->extract_here)
 				remove_directory (archive->priv->extraction_destination);
 		}
@@ -1076,7 +813,7 @@ fr_archive_create (FrArchive  *archive,
 
 	tmp_command = archive->command;
 
-	mime_type = get_mime_type_from_filename (archive->local_copy);
+	mime_type = get_mime_type_from_filename (archive->file);
 	if (! create_command_to_create_archive (archive, mime_type)) {
 		archive->command = tmp_command;
 		return FALSE;
@@ -1130,11 +867,11 @@ load_local_archive (FrArchive  *archive,
 
 	tmp_command = archive->command;
 
-	mime_type = get_mime_type_from_filename (archive->local_copy);
+	mime_type = get_mime_type_from_filename (archive->file);
 	if (! create_command_to_load_archive (archive, mime_type)) {
-		mime_type = get_mime_type_from_content (archive->local_copy);
+		mime_type = get_mime_type_from_content (archive->file);
 		if (! create_command_to_load_archive (archive, mime_type)) {
-			mime_type = get_mime_type_from_magic_numbers (archive->local_copy);
+			mime_type = get_mime_type_from_magic_numbers (archive->file);
 			if (! create_command_to_load_archive (archive, mime_type)) {
 				archive->command = tmp_command;
 				fr_archive_action_completed (archive,
@@ -1172,86 +909,6 @@ load_local_archive (FrArchive  *archive,
 }
 
 
-static void
-copy_remote_file_done (GError   *error,
-		       gpointer  user_data)
-{
-	XferData *xfer_data = user_data;
-
-	if (error != NULL)
-		fr_archive_copy_done (xfer_data->archive, FR_ACTION_LOADING_ARCHIVE, error);
-	else
-		load_local_archive (xfer_data->archive, xfer_data->uri, xfer_data->password);
-	xfer_data_free (xfer_data);
-}
-
-
-static void
-copy_remote_file_progress (goffset   current_file,
-                           goffset   total_files,
-                           GFile    *source,
-                           GFile    *destination,
-                           goffset   current_num_bytes,
-                           goffset   total_num_bytes,
-                           gpointer  user_data)
-{
-	XferData *xfer_data = user_data;
-
-	g_signal_emit (G_OBJECT (xfer_data->archive),
-		       fr_archive_signals[PROGRESS],
-		       0,
-		       (double) current_num_bytes / total_num_bytes);
-}
-
-
-static gboolean
-copy_remote_file_done_cb (gpointer user_data)
-{
-	XferData *xfer_data = user_data;
-
-	g_source_remove (xfer_data->source_id);
-	copy_remote_file_done (NULL, xfer_data);
-	return FALSE;
-}
-
-
-static void
-copy_remote_file (FrArchive  *archive,
-		  const char *password)
-{
-	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);
-	if (password != NULL)
-		xfer_data->password = g_strdup (password);
-
-	if (! archive->is_remote) {
-		xfer_data->source_id = g_idle_add (copy_remote_file_done_cb, xfer_data);
-		return;
-	}
-
-	g_copy_file_async (archive->file,
-			   archive->local_copy,
-			   G_FILE_COPY_OVERWRITE,
-			   G_PRIORITY_DEFAULT,
-			   archive->priv->cancellable,
-			   copy_remote_file_progress,
-			   xfer_data,
-			   copy_remote_file_done,
-			   xfer_data);
-}
-
-
 gboolean
 fr_archive_load (FrArchive  *archive,
 		 const char *uri,
@@ -1265,7 +922,7 @@ fr_archive_load (FrArchive  *archive,
 		       FR_ACTION_LOADING_ARCHIVE);
 
 	fr_archive_set_uri (archive, uri);
-	copy_remote_file (archive, password);
+	load_local_archive (archive, uri, password);
 
 	return TRUE;
 }
@@ -1348,7 +1005,7 @@ create_tmp_base_dir (const char *base_dir,
 	{
 		return g_strdup (base_dir);
 	}
-	
+
 	dest_dir = g_strdup (dest_path);
 	if (dest_dir[strlen (dest_dir) - 1] == G_DIR_SEPARATOR)
 		dest_dir[strlen (dest_dir) - 1] = 0;
@@ -1451,12 +1108,18 @@ convert_to_local_file_list (GList *file_list)
 	GList *scan;
 
 	for (scan = file_list; scan; scan = scan->next) {
-		char *uri = scan->data;
-		char *local_filename;
-
-		local_filename = g_uri_unescape_string (uri, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH);
+		GFile *file;
+		char  *uri = scan->data;
+		char  *local_filename;
+
+		file = g_file_new_for_uri (uri);
+		local_filename = g_file_get_path (file);
+		if (local_filename == NULL)
+			local_filename = g_strdup (uri);
 		if (local_filename != NULL)
 			local_file_list = g_list_prepend (local_file_list, local_filename);
+
+		g_object_unref (file);
 	}
 
 	return local_file_list;
@@ -1630,7 +1293,7 @@ fr_archive_add (FrArchive     *archive,
 	}
 
 	archive->command->creating_archive = ! g_file_test (archive->command->filename, G_FILE_TEST_EXISTS);
-	
+
 	fr_command_uncompress (archive->command);
 
 	/* when files are already present in a tar archive and are added
@@ -1771,145 +1434,6 @@ fr_archive_add_local_files (FrArchive     *archive,
 }
 
 
-static void
-copy_remote_files_done (GError   *error,
-			gpointer  user_data)
-{
-	XferData *xfer_data = user_data;
-
-	fr_archive_copy_done (xfer_data->archive, FR_ACTION_COPYING_FILES_FROM_REMOTE, error);
-
-	if (error == NULL)
-		fr_archive_add_local_files (xfer_data->archive,
-					    xfer_data->file_list,
-					    xfer_data->tmp_dir,
-					    xfer_data->dest_dir,
-					    FALSE,
-					    xfer_data->password,
-					    xfer_data->encrypt_header,
-					    xfer_data->compression,
-					    xfer_data->volume_size);
-	xfer_data_free (xfer_data);
-}
-
-
-static void
-copy_remote_files_progress (goffset   current_file,
-                            goffset   total_files,
-                            GFile    *source,
-                            GFile    *destination,
-                            goffset   current_num_bytes,
-                            goffset   total_num_bytes,
-                            gpointer  user_data)
-{
-	XferData *xfer_data = user_data;
-
-	g_signal_emit (G_OBJECT (xfer_data->archive),
-		       fr_archive_signals[PROGRESS],
-		       0,
-		       (double) current_file / (total_files + 1));
-}
-
-
-static void
-copy_remote_files (FrArchive     *archive,
-		   GList         *file_list,
-		   const char    *base_uri,
-		   const char    *dest_dir,
-		   gboolean       update,
-		   const char    *password,
-		   gboolean       encrypt_header,
-		   FrCompression  compression,
-		   guint          volume_size,
-		   const char    *tmp_dir)
-{
-	GList      *sources = NULL, *destinations = NULL;
-	GHashTable *created_folders;
-	GList      *scan;
-	XferData   *xfer_data;
-
-	created_folders = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
-	for (scan = file_list; scan; scan = scan->next) {
-		char  *partial_filename = scan->data;
-		char  *local_uri;
-		char  *local_folder_uri;
-		char  *remote_uri;
-
-		local_uri = g_strconcat ("file://", tmp_dir, "/", partial_filename, NULL);
-		local_folder_uri = remove_level_from_path (local_uri);
-		if (g_hash_table_lookup (created_folders, local_folder_uri) == NULL) {
-			GError *error = NULL;
-			if (! ensure_dir_exists (local_uri, 0755, &error)) {
-				g_free (local_folder_uri);
-				g_free (local_uri);
-				gio_file_list_free (sources);
-				gio_file_list_free (destinations);
-				g_hash_table_destroy (created_folders);
-
-				fr_archive_action_completed (archive,
-							     FR_ACTION_COPYING_FILES_FROM_REMOTE,
-							     FR_PROC_ERROR_GENERIC,
-							     error->message);
-				g_clear_error (&error);
-				return;
-			}
-
-			g_hash_table_insert (created_folders, local_folder_uri, GINT_TO_POINTER (1));
-		}
-		else
-			g_free (local_folder_uri);
-
-		remote_uri = g_strconcat (base_uri, "/", partial_filename, NULL);
-		sources = g_list_append (sources, g_file_new_for_uri (remote_uri));
-		g_free (remote_uri);
-
-		destinations = g_list_append (destinations, g_file_new_for_uri (local_uri));
-		g_free (local_uri);
-	}
-	g_hash_table_destroy (created_folders);
-
-	xfer_data = g_new0 (XferData, 1);
-	xfer_data->archive = archive;
-	xfer_data->file_list = path_list_dup (file_list);
-	xfer_data->base_uri = g_strdup (base_uri);
-	xfer_data->dest_dir = g_strdup (dest_dir);
-	xfer_data->update = update;
-	xfer_data->dest_dir = g_strdup (dest_dir);
-	xfer_data->password = g_strdup (password);
-	xfer_data->encrypt_header = encrypt_header;
-	xfer_data->compression = compression;
-	xfer_data->volume_size = volume_size;
-	xfer_data->tmp_dir = g_strdup (tmp_dir);
-
-	g_signal_emit (G_OBJECT (archive),
-		       fr_archive_signals[START],
-		       0,
-		       FR_ACTION_COPYING_FILES_FROM_REMOTE);
-
-	g_copy_files_async (sources,
-			    destinations,
-			    G_FILE_COPY_OVERWRITE,
-			    G_PRIORITY_DEFAULT,
-			    archive->priv->cancellable,
-			    copy_remote_files_progress,
-			    xfer_data,
-			    copy_remote_files_done,
-			    xfer_data);
-
-	gio_file_list_free (sources);
-	gio_file_list_free (destinations);
-}
-
-
-static char *
-fr_archive_get_temp_work_dir (FrArchive *archive)
-{
-	fr_archive_remove_temp_work_dir (archive);
-	archive->priv->temp_dir = get_temp_work_dir (NULL);
-	return archive->priv->temp_dir;
-}
-
-
 void
 fr_archive_add_files (FrArchive     *archive,
 		      GList         *file_list,
@@ -1921,30 +1445,23 @@ fr_archive_add_files (FrArchive     *archive,
 		      FrCompression  compression,
 		      guint          volume_size)
 {
-	if (uri_is_local (base_dir)) {
-		char *local_dir = g_filename_from_uri (base_dir, NULL, NULL);
-		fr_archive_add_local_files (archive,
-					    file_list,
-					    local_dir,
-					    dest_dir,
-					    update,
-					    password,
-					    encrypt_header,
-					    compression,
-					    volume_size);
-		g_free (local_dir);
-	}
-	else
-		copy_remote_files (archive,
-				   file_list,
-				   base_dir,
-				   dest_dir,
-				   update,
-				   password,
-				   encrypt_header,
-				   compression,
-				   volume_size,
-				   fr_archive_get_temp_work_dir (archive));
+	GFile *file;
+	char  *local_dir;
+
+	file = g_file_new_for_uri (base_dir);
+	local_dir = g_file_get_path (file);
+	fr_archive_add_local_files (archive,
+				    file_list,
+				    local_dir,
+				    dest_dir,
+				    update,
+				    password,
+				    encrypt_header,
+				    compression,
+				    volume_size);
+
+	g_free (local_dir);
+	g_object_unref (file);
 }
 
 
@@ -2855,7 +2372,7 @@ remove_files_contained_in_this_dir (GList *file_list,
 	char  *dirname = dir_pointer->data;
 	int    dirname_l = strlen (dirname);
 	GList *scan;
-	
+
 	for (scan = dir_pointer->next; scan; /* empty */) {
 		char *filename = scan->data;
 
@@ -2936,7 +2453,7 @@ fr_archive_extract_to_local (FrArchive  *archive,
 			created_filtered_list = TRUE;
 			filtered = g_list_copy (file_list);
 			filtered = g_list_sort (filtered, (GCompareFunc) strcmp);
-			for (scan = filtered; scan; scan = scan->next) 
+			for (scan = filtered; scan; scan = scan->next)
 				filtered = remove_files_contained_in_this_dir (filtered, scan);
 		}
 		else
@@ -3093,38 +2610,25 @@ fr_archive_extract (FrArchive  *archive,
 		    gboolean    junk_paths,
 		    const char *password)
 {
+	GFile *file;
+	char  *local_destination;
+
 	g_free (archive->priv->extraction_destination);
 	archive->priv->extraction_destination = g_strdup (destination);
 
-	g_free (archive->priv->temp_extraction_dir);
-	archive->priv->temp_extraction_dir = NULL;
-
-	archive->priv->remote_extraction = ! uri_is_local (destination);
-	if (archive->priv->remote_extraction) {
- 		archive->priv->temp_extraction_dir = get_temp_work_dir (NULL);
-		fr_archive_extract_to_local (archive,
-				  	     file_list,
-				  	     archive->priv->temp_extraction_dir,
-				  	     base_dir,
-				  	     skip_older,
-				  	     overwrite,
-				  	     junk_paths,
-				  	     password);
-	}
-	else {
-		char *local_destination;
-
-		local_destination = g_filename_from_uri (destination, NULL, NULL);
-		fr_archive_extract_to_local (archive,
-					     file_list,
-					     local_destination,
-					     base_dir,
-					     skip_older,
-					     overwrite,
-					     junk_paths,
-					     password);
-		g_free (local_destination);
-	}
+	file = g_file_new_for_uri (destination);
+	local_destination = g_file_get_path (file);
+	fr_archive_extract_to_local (archive,
+				     file_list,
+				     local_destination,
+				     base_dir,
+				     skip_older,
+				     overwrite,
+				     junk_paths,
+				     password);
+
+	g_free (local_destination);
+	g_object_unref (file);
 }
 
 
@@ -3151,7 +2655,7 @@ get_desired_destination_for_archive (GFile *file)
 		/* ...else use the name without the extension */
 		new_name = g_strndup (name, strlen (name) - strlen (ext));
 	new_name_escaped = g_uri_escape_string (new_name, "", FALSE);
-	
+
 	desired_destination = g_strconcat (directory_uri, "/", new_name_escaped, NULL);
 
 	g_free (new_name_escaped);
diff --git a/src/fr-archive.h b/src/fr-archive.h
index 530e49e..2c485a2 100644
--- a/src/fr-archive.h
+++ b/src/fr-archive.h
@@ -44,8 +44,6 @@ struct _FrArchive {
 	GObject  __parent;
 
 	GFile       *file;
-	GFile       *local_copy;
-	gboolean     is_remote;
 	const char  *content_type;
 	FrCommand   *command;
 	FrProcess   *process;
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index 4ce8f66..94ad0bd 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -478,6 +478,23 @@ begin_func__recompress (gpointer data)
 }
 
 
+static gboolean
+gzip_continue_func (gpointer user_data)
+{
+	FrCommand *comm = user_data;
+
+	/* ignore gzip warnings */
+
+	if (comm->process->error.status == 2) {
+		comm->process->error.type = FR_PROC_ERROR_NONE;
+		comm->process->error.status = 0;
+		g_clear_error (&comm->process->error.gerror);
+	}
+
+	return comm->process->error.status == 0;
+}
+
+
 static void
 fr_command_tar_recompress (FrCommand *comm)
 {
@@ -491,6 +508,7 @@ fr_command_tar_recompress (FrCommand *comm)
 		fr_process_begin_command (comm->process, "gzip");
 		fr_process_set_sticky (comm->process, TRUE);
 		fr_process_set_begin_func (comm->process, begin_func__recompress, comm);
+		fr_process_set_continue_func (comm->process, gzip_continue_func, comm);
 		switch (comm->compression) {
 		case FR_COMPRESSION_VERY_FAST:
 			fr_process_add_arg (comm->process, "-1"); break;
@@ -830,6 +848,7 @@ fr_command_tar_uncompress (FrCommand *comm)
 		if (is_mime_type (comm->mime_type, "application/x-compressed-tar")) {
 			fr_process_begin_command (comm->process, "gzip");
 			fr_process_set_begin_func (comm->process, begin_func__uncompress, comm);
+			fr_process_set_continue_func (comm->process, gzip_continue_func, comm);
 			fr_process_add_arg (comm->process, "-f");
 			fr_process_add_arg (comm->process, "-d");
 			fr_process_add_arg (comm->process, tmp_name);
@@ -844,8 +863,10 @@ fr_command_tar_uncompress (FrCommand *comm)
 			fr_process_end_command (comm->process);
 		}
 		else if (is_mime_type (comm->mime_type, "application/x-tarz")) {
-			if (is_program_in_path ("gzip"))
+			if (is_program_in_path ("gzip")) {
 				fr_process_begin_command (comm->process, "gzip");
+				fr_process_set_continue_func (comm->process, gzip_continue_func, comm);
+			}
 			else
 				fr_process_begin_command (comm->process, "uncompress");
 			fr_process_set_begin_func (comm->process, begin_func__uncompress, comm);
diff --git a/src/fr-command.c b/src/fr-command.c
index b006c5e..864edab 100644
--- a/src/fr-command.c
+++ b/src/fr-command.c
@@ -582,7 +582,7 @@ fr_command_set_multi_volume (FrCommand  *comm,
 
 
 void
-fr_command_list (FrCommand  *comm)
+fr_command_list (FrCommand *comm)
 {
 	g_return_if_fail (FR_IS_COMMAND (comm));
 
@@ -594,13 +594,19 @@ fr_command_list (FrCommand  *comm)
 	}
 
 	comm->action = FR_ACTION_LISTING_CONTENT;
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process, NULL, NULL);
-	fr_process_set_err_line_func (FR_COMMAND (comm)->process, NULL, NULL);
-	fr_process_use_standard_locale (FR_COMMAND (comm)->process, TRUE);
+	fr_process_set_out_line_func (comm->process, NULL, NULL);
+	fr_process_set_err_line_func (comm->process, NULL, NULL);
+	fr_process_use_standard_locale (comm->process, TRUE);
 	comm->multi_volume = FALSE;
 
-	if (!comm->fake_load)
+	if (! comm->fake_load)
 		FR_COMMAND_GET_CLASS (G_OBJECT (comm))->list (comm);
+	else
+		g_signal_emit (G_OBJECT (comm),
+			       fr_command_signals[DONE],
+			       0,
+			       comm->action,
+			       &comm->process->error);
 }
 
 
diff --git a/src/fr-process.c b/src/fr-process.c
index f7768ce..d590c60 100644
--- a/src/fr-process.c
+++ b/src/fr-process.c
@@ -133,10 +133,10 @@ fr_channel_data_read (FrChannelData *channel)
 	char  *line;
 	gsize  length;
 	gsize  terminator_pos;
-	
+
 	channel->status = G_IO_STATUS_NORMAL;
 	g_clear_error (&channel->error);
-		
+
 	while ((channel->status = g_io_channel_read_line (channel->source,
 							  &line,
 							  &length,
@@ -148,7 +148,7 @@ fr_channel_data_read (FrChannelData *channel)
 		if (channel->line_func != NULL)
 			(*channel->line_func) (line, channel->line_data);
 	}
-	
+
 	return channel->status;
 }
 
@@ -157,11 +157,11 @@ static GIOStatus
 fr_channel_data_flush (FrChannelData *channel)
 {
 	GIOStatus status;
-	
+
 	while (((status = fr_channel_data_read (channel)) != G_IO_STATUS_ERROR) && (status != G_IO_STATUS_EOF))
 		/* void */;
 	fr_channel_data_close_source (channel);
-	
+
 	return status;
 }
 
@@ -316,7 +316,7 @@ fr_process_init (FrProcess *process)
 	process->priv->running = FALSE;
 	process->priv->stopping = FALSE;
 	process->restart = FALSE;
-	
+
 	process->priv->current_charset = -1;
 
 	process->priv->use_standard_locale = FALSE;
@@ -645,12 +645,12 @@ static const char *
 fr_process_get_charset (FrProcess *process)
 {
 	const char *charset = NULL;
-	
+
 	if (process->priv->current_charset >= 0)
 		charset = try_charsets[process->priv->current_charset];
 	else if (g_get_charset (&charset))
 		charset = NULL;
-	
+
 	return charset;
 }
 
@@ -772,7 +772,7 @@ fr_process_set_error (FrProcess       *process,
 		if (gerror != NULL)
 			process->error.gerror = g_error_copy (gerror);
 	}
-}					 	
+}
 
 
 static gint
@@ -831,7 +831,7 @@ check_child (gpointer data)
 	}
 
 	process->priv->command_pid = 0;
-	
+
 	if (fr_channel_data_flush (&process->out) == G_IO_STATUS_ERROR) {
 		fr_process_set_error (process, FR_PROC_ERROR_IO_CHANNEL, 0, process->out.error);
 		channel_error = TRUE;
@@ -846,10 +846,10 @@ check_child (gpointer data)
 
 	/**/
 
-	if (channel_error 
+	if (channel_error
 	    && (process->error.type == FR_PROC_ERROR_IO_CHANNEL)
 	    && g_error_matches (process->error.gerror, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
-	{	
+	{
 		if (process->priv->current_charset < n_charsets - 1) {
 			/* try with another charset */
 			process->priv->current_charset++;
@@ -857,7 +857,7 @@ check_child (gpointer data)
 			process->restart = TRUE;
 			fr_process_start (process);
 			return FALSE;
-		}		
+		}
 		/*fr_process_set_error (process, FR_PROC_ERROR_NONE, 0, NULL);*/
 		fr_process_set_error (process, FR_PROC_ERROR_BAD_CHARSET, 0, process->error.gerror);
 	}
@@ -903,9 +903,9 @@ check_child (gpointer data)
 
 	if (process->priv->sticky_only) {
 		/* Restore the first error. */
-		fr_process_set_error (process, 
-				      process->priv->first_error.type, 
-				      process->priv->first_error.status, 
+		fr_process_set_error (process,
+				      process->priv->first_error.type,
+				      process->priv->first_error.status,
 				      process->priv->first_error.gerror);
 	}
 
diff --git a/src/fr-window.c b/src/fr-window.c
index 28b3ab6..cd5270a 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -4181,14 +4181,14 @@ get_selection_data_from_clipboard_data (FrWindow        *window,
 		      			FrClipboardData *data)
 {
 	GString *list;
-	char    *local_filename;
+	char    *archive_uri;
 	GList   *scan;
 
 	list = g_string_new (NULL);
 
-	local_filename = g_file_get_uri (window->archive->local_copy);
-	g_string_append (list, local_filename);
-	g_free (local_filename);
+	archive_uri = g_file_get_uri (window->archive->file);
+	g_string_append (list, archive_uri);
+	g_free (archive_uri);
 
 	g_string_append (list, "\r\n");
 	if (window->priv->password != NULL)
@@ -6002,12 +6002,9 @@ fr_window_archive_open (FrWindow   *current_window,
 			GtkWindow  *parent)
 {
 	FrWindow *window = current_window;
-	gboolean  new_window_created = FALSE;
 
-	if (current_window->priv->archive_present) {
-		new_window_created = TRUE;
+	if (current_window->priv->archive_present)
 		window = (FrWindow *) fr_window_new ();
-	}
 
 	g_return_val_if_fail (window != NULL, FALSE);
 
@@ -7605,13 +7602,13 @@ copy_from_archive_action_performed_cb (FrArchive   *archive,
 	case FR_ACTION_LISTING_CONTENT:
 		fr_process_clear (window->priv->copy_from_archive->process);
 		fr_archive_extract_to_local (window->priv->copy_from_archive,
-						 window->priv->clipboard_data->files,
-						 window->priv->clipboard_data->tmp_dir,
-						 NULL,
-						FALSE,
-						 TRUE,
-						FALSE,
-						window->priv->clipboard_data->archive_password);
+					     window->priv->clipboard_data->files,
+					     window->priv->clipboard_data->tmp_dir,
+					     NULL,
+					     FALSE,
+					     TRUE,
+					     FALSE,
+					     window->priv->clipboard_data->archive_password);
 		fr_process_start (window->priv->copy_from_archive->process);
 		break;
 



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