[nautilus/wip/oholy/extraction-fixes: 4/5] file-operations: Fix progress when skipping during extraction
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/oholy/extraction-fixes: 4/5] file-operations: Fix progress when skipping during extraction
- Date: Fri, 24 Sep 2021 08:03:57 +0000 (UTC)
commit 158a842efd5f909e18b082182c8db53ea14e813e
Author: Ondrej Holy <oholy redhat com>
Date: Fri Sep 24 09:56:07 2021 +0200
file-operations: Fix progress when skipping during extraction
The progress is wrong when extracting multiple files and some of them
are skipped. Let's try to fix this.
src/nautilus-file-operations.c | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
---
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index 500bad795..6c27cc754 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -205,6 +205,7 @@ typedef struct
GFile *destination_directory;
GList *output_files;
gboolean destination_decided;
+ gboolean extraction_failed;
gdouble base_progress;
@@ -8341,6 +8342,8 @@ extract_job_on_error (AutoarExtractor *extractor,
return;
}
+ extract_job->extraction_failed = TRUE;
+
if (extract_job->destination_decided)
{
destination = extract_job->output_files->data;
@@ -8562,8 +8565,7 @@ extract_job_on_scanned (AutoarExtractor *extractor,
}
static void
-report_extract_final_progress (ExtractJob *extract_job,
- gint total_files)
+report_extract_final_progress (ExtractJob *extract_job)
{
char *status;
g_autofree gchar *basename_dest = NULL;
@@ -8573,7 +8575,11 @@ report_extract_final_progress (ExtractJob *extract_job,
extract_job->destination_directory);
basename_dest = get_basename (extract_job->destination_directory);
- if (total_files == 1)
+ /* The g_list_length function is used intentionally here instead of the
+ * extract_job->total_files variable to avoid printing wrong basename in
+ * the case of skipped files.
+ */
+ if (g_list_length (extract_job->source_files) == 1)
{
GFile *source_file;
g_autofree gchar *basename = NULL;
@@ -8588,8 +8594,8 @@ report_extract_final_progress (ExtractJob *extract_job,
{
status = g_strdup_printf (ngettext ("Extracted %'d file to ā%sā",
"Extracted %'d files to ā%sā",
- total_files),
- total_files,
+ extract_job->total_files),
+ extract_job->total_files,
basename_dest);
}
@@ -8600,6 +8606,8 @@ report_extract_final_progress (ExtractJob *extract_job,
g_strdup_printf (_("%s / %s"),
formatted_size,
formatted_size));
+
+ nautilus_progress_info_set_progress (extract_job->common.progress, 1, 1);
}
static void
@@ -8681,6 +8689,7 @@ extract_task_thread_func (GTask *task,
extract_job->archive_compressed_size = archive_compressed_sizes[i];
extract_job->destination_decided = FALSE;
+ extract_job->extraction_failed = FALSE;
autoar_extractor_start (extractor,
extract_job->common.cancellable);
@@ -8688,13 +8697,23 @@ extract_task_thread_func (GTask *task,
g_signal_handlers_disconnect_by_data (extractor,
extract_job);
- extract_job->base_progress += (gdouble) extract_job->archive_compressed_size /
- (gdouble) extract_job->total_compressed_size;
+ if (!extract_job->extraction_failed)
+ {
+ extract_job->base_progress += (gdouble) extract_job->archive_compressed_size /
+ (gdouble) extract_job->total_compressed_size;
+ }
+ else
+ {
+ extract_job->total_files--;
+ extract_job->base_progress *= extract_job->total_compressed_size;
+ extract_job->total_compressed_size -= extract_job->archive_compressed_size;
+ extract_job->base_progress /= extract_job->total_compressed_size;
+ }
}
if (!job_aborted ((CommonJob *) extract_job))
{
- report_extract_final_progress (extract_job, extract_job->total_files);
+ report_extract_final_progress (extract_job);
}
if (extract_job->common.undo_info)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]