write_content_object: Don't assume file info has standard::size
authorSimon McVittie <smcv@collabora.com>
Fri, 17 Mar 2023 12:56:39 +0000 (12:56 +0000)
committerSimon McVittie <smcv@collabora.com>
Fri, 17 Mar 2023 12:56:39 +0000 (12:56 +0000)
The file info object for symlinks might validly not have this attribute.
If not, behave as though it was 0, matching what happened with older
versions of GLib.

Signed-off-by: Simon McVittie <smcv@collabora.com>
src/libostree/ostree-repo-commit.c

index 2d4347b0da5cc0b318ad2d45dd8d2fb8816608db..32119c479fd57816dc0012b35e82e78d1a6ee318 100644 (file)
@@ -1211,7 +1211,8 @@ write_content_object (OstreeRepo         *self,
   /* Update statistics */
   g_mutex_lock (&self->txn_lock);
   self->txn.stats.content_objects_written++;
-  self->txn.stats.content_bytes_written += g_file_info_get_size (file_info);
+  if (g_file_info_has_attribute (file_info, "standard::size"))
+    self->txn.stats.content_bytes_written += g_file_info_get_size (file_info);
   self->txn.stats.content_objects_total++;
   g_mutex_unlock (&self->txn_lock);