diff options
author | Karol Lewandowski <k.lewandowsk@samsung.com> | 2024-01-25 15:08:05 +0100 |
---|---|---|
committer | Karol Lewandowski <k.lewandowsk@samsung.com> | 2024-01-25 15:08:05 +0100 |
commit | 73d39c11a0c085416cc55df47f9c3fdaa8149c6b (patch) | |
tree | 9cbd7da363f80d8d492ff944bc44bb64f1d0249f /gio/gfile.c | |
parent | 28d0ab6922ac85865d2ae49d43732d8c45e78b6d (diff) | |
download | glib-73d39c11a0c085416cc55df47f9c3fdaa8149c6b.tar.gz glib-73d39c11a0c085416cc55df47f9c3fdaa8149c6b.tar.bz2 glib-73d39c11a0c085416cc55df47f9c3fdaa8149c6b.zip |
Imported Upstream version 2.76.6
Diffstat (limited to 'gio/gfile.c')
-rw-r--r-- | gio/gfile.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/gio/gfile.c b/gio/gfile.c index e78b5e185..94786c84a 100644 --- a/gio/gfile.c +++ b/gio/gfile.c @@ -3158,15 +3158,25 @@ btrfs_reflink_with_progress (GInputStream *in, gpointer progress_callback_data, GError **error) { - goffset source_size; + goffset total_size; int fd_in, fd_out; int ret, errsv; fd_in = g_file_descriptor_based_get_fd (G_FILE_DESCRIPTOR_BASED (in)); fd_out = g_file_descriptor_based_get_fd (G_FILE_DESCRIPTOR_BASED (out)); + total_size = -1; + /* avoid performance impact of querying total size when it's not needed */ if (progress_callback) - source_size = g_file_info_get_size (info); + { + struct stat sbuf; + + if (fstat (fd_in, &sbuf) == 0) + total_size = sbuf.st_size; + } + + if (total_size == -1) + total_size = 0; /* Btrfs clone ioctl properties: * - Works at the inode level @@ -3201,7 +3211,7 @@ btrfs_reflink_with_progress (GInputStream *in, /* Make sure we send full copied size */ if (progress_callback) - progress_callback (source_size, source_size, progress_callback_data); + progress_callback (total_size, total_size, progress_callback_data); return TRUE; } @@ -3462,9 +3472,9 @@ file_copy_fallback (GFile *source, * @flags: set of #GFileCopyFlags * @cancellable: (nullable): optional #GCancellable object, * %NULL to ignore - * @progress_callback: (nullable) (scope call): function to callback with + * @progress_callback: (nullable) (scope call) (closure progress_callback_data): function to callback with * progress information, or %NULL if progress information is not needed - * @progress_callback_data: (closure): user data to pass to @progress_callback + * @progress_callback_data: user data to pass to @progress_callback * @error: #GError to set on error, or %NULL * * Copies the file @source to the location specified by @destination. @@ -3670,9 +3680,9 @@ g_file_copy_finish (GFile *file, * @flags: set of #GFileCopyFlags * @cancellable: (nullable): optional #GCancellable object, * %NULL to ignore - * @progress_callback: (nullable) (scope call): #GFileProgressCallback + * @progress_callback: (nullable) (scope call) (closure progress_callback_data): #GFileProgressCallback * function for updates - * @progress_callback_data: (closure): gpointer to user data for + * @progress_callback_data: gpointer to user data for * the callback function * @error: #GError for returning error conditions, or %NULL * @@ -7773,7 +7783,7 @@ g_file_load_contents (GFile *file, NULL); if (info) { - *etag_out = g_strdup (g_file_info_get_etag (info)); + *etag_out = g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ETAG_VALUE) ? g_strdup (g_file_info_get_etag (info)) : NULL; g_object_unref (info); } } @@ -7847,7 +7857,7 @@ load_contents_fstat_callback (GObject *obj, stat_res, NULL); if (info) { - data->etag = g_strdup (g_file_info_get_etag (info)); + data->etag = g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ETAG_VALUE) ? g_strdup (g_file_info_get_etag (info)) : NULL; g_object_unref (info); } |