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 773057 - Provide document file size
Provide document file size
Status: RESOLVED FIXED
Product: libgdata
Classification: Platform
Component: Google Documents service
git master
Other Linux
: Normal normal
: ---
Assigned To: libgdata-maint
libgdata-maint
Depends on:
Blocks: 773053
 
 
Reported: 2016-10-16 21:55 UTC by david
Modified: 2017-03-23 15:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add file-size property to document (5.41 KB, patch)
2016-10-16 22:46 UTC, david
none Details | Review
Add file-size property to document (5.41 KB, patch)
2016-10-16 22:55 UTC, david
none Details | Review
Add file-size property to document (6.57 KB, patch)
2016-10-25 04:31 UTC, david
none Details | Review
Add file-size property to document (6.57 KB, patch)
2016-10-25 04:32 UTC, david
committed Details | Review
Example file-size use (929 bytes, patch)
2016-10-25 04:49 UTC, david
none Details | Review

Description david 2016-10-16 21:55:50 UTC
For #773053 gvfs needs to be able to get the size of a Google Drive document. This currently seems not to be possible.
Comment 1 david 2016-10-16 22:46:01 UTC
Created attachment 337798 [details] [review]
Add file-size property to document
Comment 2 david 2016-10-16 22:55:49 UTC
Created attachment 337799 [details] [review]
Add file-size property to document

Fixing author email.
Comment 3 Philip Withnall 2016-10-18 16:58:41 UTC
Review of attachment 337799 [details] [review]:

> From: David Newgas <dnewgas@google.com>

Are you contributing this as a Google employee? If so, I think you’re the first Google employee to contribute to libgdata. :-)

Thanks for the patch!

::: gdata/services/documents/gdata-documents-entry.c
@@ +299,3 @@
+	 *
+	 * The size of the document. Currently, only arbitrary files consume file space quota (whereas standard document
+	 * formats, such as #GDataDocumentsText, #GDataDocumentsSpreadsheet and #GDataDocumentsFolder don't). Measured in bytes.

Should this documentation be changed from GDataDocumentsEntry:quota-used, since the idea of this property is to give the file size *even* for known document types?

It would be a good idea to expand the documentation for GDataDocumentsEntry:quota-used to say something like “See #GDataDocumentsEntry:file-size to get the size of a file, regardless of whether it uses any quota.”.

@@ +301,3 @@
+	 * formats, such as #GDataDocumentsText, #GDataDocumentsSpreadsheet and #GDataDocumentsFolder don't). Measured in bytes.
+	 *
+	 * Since: 0.17.7

Please use `Since: UNRELEASED`, so that the version number is right regardless of when this patch lands. (`UNRELEASED` gets changed to the release number in the commit which makes a release.)

@@ +1128,3 @@
+ * Return value: the size of the document in bytes
+ *
+ * Since: 0.17.7

`Since: UNRELEASED` please.

@@ +1131,3 @@
+ */
+goffset
+gdata_documents_entry_get_file_size (GDataDocumentsEntry *self)

This new function should be added to `docs/reference/gdata-sections.txt` and `gdata/gdata-core.symbols`.

Could you also please add assertions checking its value in `gdata/tests/documents.c`?
Comment 4 david 2016-10-18 19:44:13 UTC
(In reply to Philip Withnall from comment #3)
> Review of attachment 337799 [details] [review] [review]:
> 
> > From: David Newgas <dnewgas@google.com>
> 
> Are you contributing this as a Google employee? If so, I think you’re the
> first Google employee to contribute to libgdata. :-)
> 
> Thanks for the patch!

I'm doing this personally, and it isn't related to my work at Google. However I believe Google does own the copyright on this contribution - I have approval to send the patch and for it to be included under the LGPL. The google.com address is a requirement of this.

> 
> ::: gdata/services/documents/gdata-documents-entry.c
> @@ +299,3 @@
> +	 *
> +	 * The size of the document. Currently, only arbitrary files consume file
> space quota (whereas standard document
> +	 * formats, such as #GDataDocumentsText, #GDataDocumentsSpreadsheet and
> #GDataDocumentsFolder don't). Measured in bytes.
> 
> Should this documentation be changed from GDataDocumentsEntry:quota-used,
> since the idea of this property is to give the file size *even* for known
> document types?

I tried out the API on a Google Doc and file-size wasn't populated, so I believe the caveat applies here too. I will re-word to remove the reference to "quota" which is a copy-pate error.

> It would be a good idea to expand the documentation for
> GDataDocumentsEntry:quota-used to say something like “See
> #GDataDocumentsEntry:file-size to get the size of a file, regardless of
> whether it uses any quota.”.

Will do.

> @@ +301,3 @@
> +	 * formats, such as #GDataDocumentsText, #GDataDocumentsSpreadsheet and
> #GDataDocumentsFolder don't). Measured in bytes.
> +	 *
> +	 * Since: 0.17.7
> 
> Please use `Since: UNRELEASED`, so that the version number is right
> regardless of when this patch lands. (`UNRELEASED` gets changed to the
> release number in the commit which makes a release.)
> 
> @@ +1128,3 @@
> + * Return value: the size of the document in bytes
> + *
> + * Since: 0.17.7
> 
> `Since: UNRELEASED` please.

I didn't know how this was done, so I just guessed the next release. I will change this.

> @@ +1131,3 @@
> + */
> +goffset
> +gdata_documents_entry_get_file_size (GDataDocumentsEntry *self)
> 
> This new function should be added to `docs/reference/gdata-sections.txt` and
> `gdata/gdata-core.symbols`.
> 
> Could you also please add assertions checking its value in
> `gdata/tests/documents.c`?

Will do.
Comment 5 Philip Withnall 2016-10-18 19:50:21 UTC
(In reply to david from comment #4)
> (In reply to Philip Withnall from comment #3)
> > Review of attachment 337799 [details] [review] [review] [review]:
> > 
> > > From: David Newgas <dnewgas@google.com>
> > 
> > Are you contributing this as a Google employee? If so, I think you’re the
> > first Google employee to contribute to libgdata. :-)
> > 
> > Thanks for the patch!
> 
> I'm doing this personally, and it isn't related to my work at Google.
> However I believe Google does own the copyright on this contribution - I
> have approval to send the patch and for it to be included under the LGPL.
> The google.com address is a requirement of this.

Cool, thanks for explaining.

> > ::: gdata/services/documents/gdata-documents-entry.c
> > @@ +299,3 @@
> > +	 *
> > +	 * The size of the document. Currently, only arbitrary files consume file
> > space quota (whereas standard document
> > +	 * formats, such as #GDataDocumentsText, #GDataDocumentsSpreadsheet and
> > #GDataDocumentsFolder don't). Measured in bytes.
> > 
> > Should this documentation be changed from GDataDocumentsEntry:quota-used,
> > since the idea of this property is to give the file size *even* for known
> > document types?
> 
> I tried out the API on a Google Doc and file-size wasn't populated, so I
> believe the caveat applies here too. I will re-word to remove the reference
> to "quota" which is a copy-pate error.

The documentation says:
> The size of the file in bytes. This field is only populated for files with content stored in Drive; it is not populated for Google Docs or shortcut files.

https://developers.google.com/drive/v2/reference/files#fileSize
Comment 6 david 2016-10-25 04:31:07 UTC
Created attachment 338378 [details] [review]
Add file-size property to document

- I tested out with a sheet, and it also had no fileSize, which makes sense as it's still not a binary object we uploaded. I have tried to make the comment as clear as possible about when a fileSize is expected. I think the v2 docs were being a bit terse in just saying "docs and links". The v3 docs refer to "binary files" (https://developers.google.com/drive/v3/reference/files#size)

- I have still not implemented any tests as gdata/tests/documents.c is based around the old gdata API rather than the REST API. I don't think I'm up to the task of porting the whole test suite.
Comment 7 david 2016-10-25 04:32:01 UTC
Created attachment 338379 [details] [review]
Add file-size property to document

- I tested out with a sheet, and it also had no fileSize, which makes sense as it's still not a binary object we uploaded. I have tried to make the comment as clear as possible about when a fileSize is expected. I think the v2 docs were being a bit terse in just saying "docs and links". The v3 docs refer to "binary files" (https://developers.google.com/drive/v3/reference/files#size)

- I have still not implemented any tests as gdata/tests/documents.c is based around the old gdata API rather than the REST API. I don't think I'm up to the task of porting the whole test suite.
Comment 8 david 2016-10-25 04:49:59 UTC
Created attachment 338380 [details] [review]
Example file-size use

Attached is a brief alteration of the demo so you can see that this code actually works. It does highlight that there is no distinguishing 0 size from no size, but that is the same with the quota property.
Comment 9 Philip Withnall 2016-11-06 18:19:28 UTC
Works for me, thanks for the patch. Pushed to master.
Comment 10 Debarshi Ray 2017-03-23 15:22:33 UTC
Thanks for the patch David!

When I did the initial port to Drive API v2, I was trying to get as far as possible without adding new libgdata API, but you have clearly demonstrated (bug 773053) the need for this.