diff options
Diffstat (limited to 'autoarchive')
-rw-r--r-- | autoarchive/autoar-extract.c | 30 | ||||
-rw-r--r-- | autoarchive/test-extract.c | 6 |
2 files changed, 16 insertions, 20 deletions
diff --git a/autoarchive/autoar-extract.c b/autoarchive/autoar-extract.c index 8972f946b..3eda97811 100644 --- a/autoarchive/autoar-extract.c +++ b/autoarchive/autoar-extract.c @@ -275,7 +275,6 @@ libarchive_read_open_cb (struct archive *ar_read, { AutoarExtract *arextract; GFile *file; - GFileInfo *fileinfo; g_debug ("libarchive_read_open_cb: called"); @@ -286,16 +285,6 @@ libarchive_read_open_cb (struct archive *ar_read, file = g_file_new_for_commandline_arg (arextract->priv->source); - fileinfo = g_file_query_info (file, - G_FILE_ATTRIBUTE_STANDARD_SIZE, - G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, - NULL, - &(arextract->priv->error)); - g_return_val_if_fail (arextract->priv->error == NULL, ARCHIVE_FATAL); - - arextract->priv->size = g_file_info_get_size (fileinfo); - g_object_unref (fileinfo); - arextract->priv->istream = (GInputStream*)g_file_read (file, NULL, &(arextract->priv->error)); @@ -351,8 +340,6 @@ libarchive_read_read_cb (struct archive *ar_read, &(arextract->priv->error)); g_return_val_if_fail (arextract->priv->error == NULL, -1); - arextract->priv->completed_size += read_size; - g_debug ("libarchive_read_read_cb: %lu", read_size); return read_size; } @@ -481,6 +468,11 @@ autoar_extract_do_write_entry (AutoarExtract *arextract, if (ostream != NULL) { if (archive_entry_size(entry) > 0) { while (archive_read_data_block (a, &buffer, &size, &offset) == ARCHIVE_OK) { + /* buffer == NULL occurs in some zip archives when an entry is + * completely read. We just skip this situation to prevent GIO + * warnings. */ + if (buffer == NULL) + continue; g_output_stream_write_all (ostream, buffer, size, @@ -493,6 +485,12 @@ autoar_extract_do_write_entry (AutoarExtract *arextract, g_object_unref (info); return; } + arextract->priv->completed_size += written; + g_signal_emit (arextract, + autoar_extract_signals[PROGRESS], + 0, + ((double)(arextract->priv->completed_size)) / ((double)(arextract->priv->size)), + ((double)(arextract->priv->completed_files)) / ((double)(arextract->priv->files))); } } g_output_stream_close (ostream, NULL, NULL); @@ -820,8 +818,9 @@ autoar_extract_start (AutoarExtract* arextract) has_top_level_dir = FALSE; } } - archive_read_data_skip (a); arextract->priv->files++; + arextract->priv->size += archive_entry_size (entry); + archive_read_data_skip (a); } g_free (pathname_prefix); archive_read_close (a); @@ -875,9 +874,6 @@ autoar_extract_start (AutoarExtract* arextract) archive_read_support_filter_all (a); archive_read_support_format_all (a); - /* We have to reset completed_size because it have been modified in Step 1 */ - arextract->priv->completed_size = 0; - r = archive_read_open (a, arextract, libarchive_read_open_cb, diff --git a/autoarchive/test-extract.c b/autoarchive/test-extract.c index 58e133222..d122ca47a 100644 --- a/autoarchive/test-extract.c +++ b/autoarchive/test-extract.c @@ -30,7 +30,7 @@ my_handler_progress (AutoarExtract *arextract, gdouble fraction_files, gpointer data) { - g_print ("Progress: Archive Size %.2lf %%, Files %.2lf %%\n", + g_print ("\rProgress: Archive Size %.2lf %%, Files %.2lf %%", fraction_size * 100, fraction_files * 100); } @@ -40,7 +40,7 @@ my_handler_error (AutoarExtract *arextract, GError *error, gpointer data) { - g_printerr ("Error: %s\n", error->message); + g_printerr ("\nError: %s\n", error->message); g_error_free (error); exit (1); } @@ -49,7 +49,7 @@ static void my_handler_completed (AutoarExtract *arextract, gpointer data) { - g_print ("Completed!\n"); + g_print ("\nCompleted!\n"); exit (0); } |