core: Ensure glib standard::size attribute is always set
authorEvan Anderson <evan@eaanderson.com>
Thu, 16 Mar 2023 02:33:21 +0000 (21:33 -0500)
committerEvan Anderson <evan@eaanderson.com>
Thu, 16 Mar 2023 03:15:55 +0000 (22:15 -0500)
* A recent change in glib [1] requires that the appropriate attribute
be available when calling getters. ostree core only sets this attribute
on regular files, and frequently triggers the critical warning. Solve
this by setting standard::size to zero for non-regular files.

Fixes https://github.com/ostreedev/ostree/issues/2827

[1]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3261

src/libostree/ostree-core.c

index 56b381d91827092664d047d10e3cd38cfcaa3163..0d1b0d5d0ca8498e7b4a5cc9d42d58ac84ebb2c7 100644 (file)
@@ -1739,6 +1739,8 @@ _ostree_stbuf_to_gfileinfo (const struct stat *stbuf)
 
   if (S_ISREG (mode))
     g_file_info_set_attribute_uint64 (ret, "standard::size", stbuf->st_size);
+  else
+    g_file_info_set_attribute_uint64 (ret, "standard::size", 0);
 
   return ret;
 }