From 3f97d75e066cdcb74f889457e7c7cc178047d4e3 Mon Sep 17 00:00:00 2001 From: Ernestas Kulik Date: Tue, 16 Aug 2016 19:38:13 +0300 Subject: file-operations: update progress on skip Currently, the transfer info of an operation is only modified if it is successful, resulting in a confusing reflection in the UI. Treating skipped operations as completed and displaying them as such feels more natural, as they are technically completed (i.e. nothing has been done). This commit changes the behavior as such. https://bugzilla.gnome.org/show_bug.cgi?id=769383 --- src/nautilus-file-operations.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c index cc2a54ed1..8cca71ba9 100644 --- a/src/nautilus-file-operations.c +++ b/src/nautilus-file-operations.c @@ -2011,6 +2011,29 @@ skip: g_error_free (error); } +static void +transfer_add_file_to_count (GFile *file, + CommonJob *job, + TransferInfo *transfer_info) +{ + g_autoptr (GFileInfo) file_info; + + if (g_cancellable_is_cancelled (job->cancellable)) { + return; + } + + file_info = g_file_query_info (file, + G_FILE_ATTRIBUTE_STANDARD_SIZE, + G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, + job->cancellable, + NULL); + + transfer_info->num_files++; + if (file_info != NULL) { + transfer_info->num_bytes += g_file_info_get_size (file_info); + } +} + static void trash_files (CommonJob *job, GList *files, @@ -2053,6 +2076,9 @@ trash_files (CommonJob *job, TRUE, &to_delete); if (skipped_file) { (*files_skipped)++; + transfer_file_add_to_count (file, job, &transfer_info); + report_trash_progress (job, &source_info, &transfer_info); + } } @@ -3927,6 +3953,12 @@ copy_move_directory (CopyMoveJob *copy_job, copy_move_file (copy_job, src_file, *dest, same_fs, FALSE, &dest_fs_type, source_info, transfer_info, NULL, NULL, FALSE, &local_skipped_file, readonly_source_fs); + + if (local_skipped_file) { + transfer_file_add_to_count (src_file, job, transfer_info); + report_copy_progress (copy_job, source_info, transfer_info); + } + g_object_unref (src_file); g_object_unref (info); } @@ -4889,6 +4921,11 @@ copy_files (CopyMoveJob *job, point, FALSE, &skipped_file, readonly_source_fs); g_object_unref (dest); + + if (skipped_file) { + transfer_file_add_to_count (src, common, transfer_info); + report_copy_progress (job, source_info, transfer_info); + } } i++; } @@ -5458,6 +5495,11 @@ common = &job->common; job->debuting_files, point, fallback->overwrite, &skipped_file, FALSE); i++; + + if (skipped_file) { + transfer_file_add_to_count (src, common, transfer_info); + report_copy_progress (job, source_info, transfer_info); + } } } -- cgit v1.2.1