GNOME Bugzilla – Bug 725782
gio reports wrong size for files
Last modified: 2014-03-06 07:08:50 UTC
Test program below compiled with gcc -Wall -O2 gio-test.c `pkg-config --libs --cflags glib-2.0 gio-2.0` ./a.out size=1883 That file is more than 1883 bytes, however: wget --debug http://www.gnumeric.org/ [...] Content-Length: 5286 [...] That's accurate: ls -l ../../www-gnumeric-org/index.html -rw-r--r-- 1 welinder welinder 5286 Mar 3 19:49 ../../www-gnumeric-org/index.html Here's what's wrong: gio, somehow, negotiates gzip content-encoding and 1883 is the size of that. #include <glib.h> #include <gio/gio.h> int main (int argc, char **argv) { const char *uri = "http://www.gnumeric.org/"; GFile *file = g_file_new_for_uri (uri); GFileInfo *info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, NULL, NULL); long filesize = g_file_info_get_size (info); g_printerr ("size=%ld\n", filesize); return 0; }
In GVFS, gvfsbackendhttp uses libsoup to set the file size based on the Content-Length field returned in the HTTP header. (See https://git.gnome.org/browse/gvfs/tree/daemon/gvfsbackendhttp.c#n597 ). It should check the Content-Encoding field to see if the content is being compressed. (It would be nice if we could do something like send a request in a SoupSession with compression disabled to get the actual file's size and transfer the file compressed in a different session). Anyways, it's definitely a GVFS bug.
*** This bug has been marked as a duplicate of bug 690226 ***