GNOME Bugzilla – Bug 773057
Provide document file size
Last modified: 2017-03-23 15:22:33 UTC
For #773053 gvfs needs to be able to get the size of a Google Drive document. This currently seems not to be possible.
Created attachment 337798 [details] [review] Add file-size property to document
Created attachment 337799 [details] [review] Add file-size property to document Fixing author email.
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`?
(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.
(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
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.
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.
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.
Works for me, thanks for the patch. Pushed to master.
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.