Strange behavior of GFileEnumerator with GVfs locations
GLib 2.70.0
Not sure if there is really a problem here, but maybe there is room for improvement, at least concerning the documentation.
-
When I get a GFileEnumerator by
g_file_enumerate_children()
in a GVfs location, and then request the file information byg_file_enumerator_next_files_async()
, I get the error: "Can't do asynchronous next_files() on a file enumerator created synchronously".This is not the case when it is not a GVfs location, and I don't see the connection between the method of getting the GFileEnumerator and the method of getting the file information.
-
If I now run the same code in a flatpak, then the above error disappears, including for GVfs locations. However, and only for GVfs locations, it becomes necessary to add
"standard::name"
to the list of attributes requested ing_file_enumerate_children()
in order to be able to invokeg_file_enumerator_get_child()
afterwards. Otherwise, this function returns NULL with the error "g_file_get_child: assertion 'name != NULL' failed", i.e.g_file_info_get_name()
returns NULL.Again, it is not clear why, only in some cases,
"standard::name"
is needed.
In the end, the solution to both problems seems to be to invoke only asynchronous methods or only synchronous methods on the one hand, and to always add "standard::name"
or to always specify "standard::*"
on the other hand. So we can consider that there is not really a problem, as I said at the beginning, but maybe something to improve.