After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 725782 - gio reports wrong size for files
gio reports wrong size for files
Status: RESOLVED DUPLICATE of bug 690226
Product: gvfs
Classification: Core
Component: http backend
unspecified
Other All
: Normal major
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2014-03-06 02:00 UTC by Morten Welinder
Modified: 2014-03-06 07:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Morten Welinder 2014-03-06 02:00:38 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;
}
Comment 1 A. Walton 2014-03-06 02:36:42 UTC
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.
Comment 2 Ross Lagerwall 2014-03-06 07:08:50 UTC

*** This bug has been marked as a duplicate of bug 690226 ***