[file-roller: 109/123] libarchive: delete the temp file if an error occurred



commit 2b0b9c24d3e4d4066ee12e0da0feb9916394f0b3
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Aug 6 12:11:50 2012 +0200

    libarchive: delete the temp file if an error occurred

 src/fr-archive-libarchive.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/fr-archive-libarchive.c b/src/fr-archive-libarchive.c
index 195388e..6b4262a 100644
--- a/src/fr-archive-libarchive.c
+++ b/src/fr-archive-libarchive.c
@@ -198,11 +198,11 @@ load_data_read (struct archive  *a,
 		return -1;
 
 	*buff = load_data->buffer;
-	bytes =g_input_stream_read (load_data->istream,
-				    load_data->buffer,
-				    load_data->buffer_size,
-				    load_data->cancellable,
-				    &load_data->error);
+	bytes = g_input_stream_read (load_data->istream,
+				     load_data->buffer,
+				     load_data->buffer_size,
+				     load_data->cancellable,
+				     &load_data->error);
 
 	/* update the progress only if listing the content */
 	if (g_simple_async_result_get_source_tag (load_data->result) == fr_archive_list) {
@@ -776,11 +776,15 @@ save_data_close (struct archive *a,
 	SaveData *save_data = client_data;
 	LoadData *load_data = LOAD_DATA (save_data);
 
-	if (load_data->error != NULL)
-		return ARCHIVE_FATAL;
+	if (save_data->ostream != NULL) {
+		GError *error = NULL;
 
-	if (save_data->ostream != NULL)
-		g_output_stream_close (save_data->ostream, load_data->cancellable, &load_data->error);
+		g_output_stream_close (save_data->ostream, load_data->cancellable, &error);
+		if (load_data->error == NULL && error != NULL)
+			load_data->error = g_error_copy (error);
+
+		_g_error_free (error);
+	}
 
 	if (load_data->error == NULL)
 		g_file_move (save_data->tmp_file,



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