Fix mimeType loss during file creation or update.
ClosedPublic

Authored by barchiesi on Jul 21 2019, 7:08 PM.

Details

Summary

LibKGAPI allows specifying the mimeType of an upload via the associated KGAPI2::Drive::File.
This is required in uploads where the data isn't sufficient in determining the mime-type (i.e. docx files as reported in BUG 401151).

BUG: 401151

Diff Detail

Repository
R219 KIO GDrive
Branch
arcpatch-D22628
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 14239
Build 14257: arc lint + arc unit
barchiesi requested review of this revision.Jul 21 2019, 7:08 PM
barchiesi created this revision.
barchiesi edited the summary of this revision. (Show Details)Jul 21 2019, 7:11 PM
barchiesi added a reviewer: elvisangelaccio.
barchiesi added a project: KIO GDrive.
barchiesi added a subscriber: KIO GDrive.

Can you expland a bit the commit message explaining how does libkgapi use the filename?

src/kio_gdrive.cpp
746

Doesn't this result in temp files such as /tmp/XXXXXXfoo.txt ? Don't we need a slash between the template and the filename?

barchiesi added inline comments.Jul 21 2019, 8:35 PM
src/kio_gdrive.cpp
746

Indeed, those would be the resulting temp filenames, as opposed to the current /tmp/XXXXXX. I believe adding a slash would result in a unique folder named XXXXXX (with inside only foo.txt) being created relative to the current working directory (per doc).

src/kio_gdrive.cpp
746

Ah right. Can we use a - as separator then? ( /tmp/XXXXXX-foo.txt )

barchiesi edited the summary of this revision. (Show Details)Jul 21 2019, 8:54 PM
barchiesi updated this revision to Diff 62238.Jul 21 2019, 8:58 PM

Added dash in temporary file template.

dvratil added inline comments.
src/kio_gdrive.cpp
746

Maybe the LibKGAPI API should be extended to allow the caller to specify the mime type, because the caller is always more knowledgable about the file than LibKGAPI, and use QMimeDatabase::mimeTypeForFileNameAndData() just as a fallback when caller doesn't provide the mime type.

Putting the real filename into /tmp is a potential privacy leak - other users of the system might be able to see what you are uploading.

barchiesi added inline comments.Jul 23 2019, 10:26 PM
src/kio_gdrive.cpp
746

That indeed seems like a better idea. I'll look into that and try to also tackle the TODO at line 666 of this file.

// TODO: Instead of using a temp file, upload directly the raw data (requires
// support in LibKGAPI)
barchiesi updated this revision to Diff 62689.Jul 28 2019, 6:31 PM

Adapted according to changes to LibKGAPI in D22787

Note that the commit message will need BUG: (with the colons) in order to automagically close the bug report.

src/kio_gdrive.cpp
692–693

I'd just use QMimeDatabase().mimeTypeForFileNameAndData(f...)

745

This comment is now obsolete. I'd just remove it.

793

Same

barchiesi updated this revision to Diff 62701.Jul 28 2019, 8:29 PM

Fixed above

barchiesi edited the summary of this revision. (Show Details)Jul 28 2019, 8:30 PM
elvisangelaccio accepted this revision.Aug 3 2019, 10:40 AM
This revision is now accepted and ready to land.Aug 3 2019, 10:40 AM
This revision was automatically updated to reflect the committed changes.