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 774937 - Unable to preview LOKDocView-supported documents from OneDrive
Unable to preview LOKDocView-supported documents from OneDrive
Status: RESOLVED FIXED
Product: gnome-documents
Classification: Core
Component: general
3.22.x
Other All
: Normal major
: ---
Assigned To: GNOME documents maintainer(s)
GNOME documents maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-11-23 16:04 UTC by mkrajnak
Modified: 2017-04-20 17:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
documents: Track nfo:fileName for later use (1.62 KB, patch)
2017-03-30 16:49 UTC, Debarshi Ray
committed Details | Review
documents: Add property to denote the URI to be loaded by the preview (4.77 KB, patch)
2017-03-30 16:49 UTC, Debarshi Ray
committed Details | Review
documents: Use logError to report loading failures (1.04 KB, patch)
2017-03-30 16:49 UTC, Debarshi Ray
committed Details | Review
documents: Let everybody provide their own download implementation (3.55 KB, patch)
2017-03-30 16:49 UTC, Debarshi Ray
none Details | Review
documents: Implement the downloadImpl vfunc for SkydriveDocument (3.58 KB, patch)
2017-03-30 16:50 UTC, Debarshi Ray
none Details | Review
documents: Fix previewing of LOKDocView-supported OneDrive documents (3.74 KB, patch)
2017-03-30 16:50 UTC, Debarshi Ray
none Details | Review
documents: Let everybody provide their own download implementation (3.47 KB, patch)
2017-03-31 15:33 UTC, Debarshi Ray
none Details | Review
documents: Strip the D-Bus error name from the UI string (898 bytes, patch)
2017-03-31 15:33 UTC, Debarshi Ray
reviewed Details | Review
documents: Let everybody provide their own download implementation (2.53 KB, patch)
2017-04-04 17:32 UTC, Debarshi Ray
committed Details | Review
documents: Implement the downloadImpl vfunc for SkydriveDocument (3.38 KB, patch)
2017-04-04 17:32 UTC, Debarshi Ray
committed Details | Review
documents, pdf-loader: Fix previewing of ODFs and OOXMLs on OneDrive (15.76 KB, patch)
2017-04-05 14:16 UTC, Debarshi Ray
none Details | Review
documents, pdf-loader: Fix previewing of ODFs and OOXMLs on OneDrive (15.70 KB, patch)
2017-04-07 11:44 UTC, Debarshi Ray
committed Details | Review
documents: Fix the retrieval of the cache's modification time (957 bytes, patch)
2017-04-20 09:58 UTC, Debarshi Ray
committed Details | Review

Description mkrajnak 2016-11-23 16:04:20 UTC
Description of problem:
Preview of documents stored on Microsoft One Drive are failing.

Version-Release number of selected component (if applicable):
gnome-documents-3.22.0-1.fc25.x86_64


How reproducible:
always

Steps to Reproduce:
1. Login to Microsoft account via GOA
2. Run documents
3. Wait for online documents to load
4. Select the documents stored in One drive

Actual results:
Document overview is opened, but no actual document content is rendered.

Expected results:
Document preview should be rendered

Additional info:
Comment 1 Debarshi Ray 2017-03-28 14:09:49 UTC
What kind of documents are you trying to access? I can open PDFs stored on OneDrive.
Comment 2 Debarshi Ray 2017-03-29 15:11:11 UTC
mkrajnak confirmed that the problem is with ODFs, OOXMLs, etc. and I can reproduce it. Patch coming up.
Comment 3 Debarshi Ray 2017-03-30 16:49:12 UTC
Created attachment 349003 [details] [review]
documents: Track nfo:fileName for later use
Comment 4 Debarshi Ray 2017-03-30 16:49:26 UTC
Created attachment 349004 [details] [review]
documents: Add property to denote the URI to be loaded by the preview
Comment 5 Debarshi Ray 2017-03-30 16:49:44 UTC
Created attachment 349005 [details] [review]
documents: Use logError to report loading failures
Comment 6 Debarshi Ray 2017-03-30 16:49:58 UTC
Created attachment 349006 [details] [review]
documents: Let everybody provide their own download implementation
Comment 7 Debarshi Ray 2017-03-30 16:50:12 UTC
Created attachment 349007 [details] [review]
documents: Implement the downloadImpl vfunc for SkydriveDocument
Comment 8 Debarshi Ray 2017-03-30 16:50:26 UTC
Created attachment 349008 [details] [review]
documents: Fix previewing of LOKDocView-supported OneDrive documents
Comment 9 Debarshi Ray 2017-03-30 16:51:17 UTC
Unfortunately, communication with OneDrive is extremely flaky for me today. It makes it very hard for me to test this as well I'd like to. So any help in that regard is very welcome.
Comment 10 Cosimo Cecchi 2017-03-30 23:20:24 UTC
Review of attachment 349003 [details] [review]:

OK
Comment 11 Cosimo Cecchi 2017-03-30 23:22:53 UTC
Review of attachment 349005 [details] [review]:

OK
Comment 12 Cosimo Cecchi 2017-03-30 23:29:03 UTC
Review of attachment 349004 [details] [review]:

This looks good but at the same time, if different backends have different network capabilities (some that can load from the network, and some that can't), it feels a bit awkward to go necessarily through an URI for all of them.
Comment 13 Cosimo Cecchi 2017-03-30 23:31:19 UTC
Review of attachment 349006 [details] [review]:

::: src/documents.js
@@ +399,3 @@
+                }));
+        } else {
+                        info = object.query_info_finish(res);

Nitpick: prefer checking for this case upfront and returning early.

@@ +423,3 @@
+                             'Cannot set mtime on the cache file; cache will not be valid after the file has ' +
+                             'been viewed.');
+                    }

No semicolon needed here.
Comment 14 Cosimo Cecchi 2017-03-30 23:32:15 UTC
Review of attachment 349007 [details] [review]:

OK
Comment 15 Cosimo Cecchi 2017-03-30 23:33:06 UTC
Review of attachment 349008 [details] [review]:

Looks good.
Comment 16 Debarshi Ray 2017-03-31 14:44:45 UTC
(In reply to Cosimo Cecchi from comment #12)
> Review of attachment 349004 [details] [review] [review]:
> 
> This looks good but at the same time, if different backends have different
> network capabilities (some that can load from the network, and some that
> can't), it feels a bit awkward to go necessarily through an URI for all of
> them.

I used an URI instead of a path simply because an URI is more flexible, and, hence, more future-proof. However, right now they are only going to be file:// URIs.

I also want to improve the network efficiency of gnome-documents (and also gnome-photos) a bit. For example, even if some remote content has native support in GIO/GVfs, I'd like to have an offline cache. As far as I know, GVfs doesn't do caching at the moment, so it is up to the application, and I think we already doing that for ownCloud and the other remote types. (Apart from some bugs where we hit the network even though we don't need to.)

So far all the caching was encapsulated inside GdPdfLoader. However we now have preview widgets other than EvView so things need not be tied to PDF anymore. So, I want to separate the caching from the previewing technology. The widgets only load from this property that points to the local/offline copy of the document, or the 'docModel'. It's upto the DocCommon subclasses to deal with the caching and ensuring that the property and the docModel are valid.

Then going forward, we can drastically simplify GdPdfLoader by removing all the unoconv bits, moving the network communication to JavaScript, and just having an introspectable API that loads a EvDocumentModel from a URI (assuming that's not introspectable).

However, I have a feeling that I misunderstood you. So, if this is not what you meant, could you expand a bit? :)
Comment 17 Debarshi Ray 2017-03-31 15:27:36 UTC
I just got this along with the "Oops! Unable to load ..." message:
GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._rest_2dproxy_2derror_2dquark.Code5: Connection terminated unexpectedly

The corresponding backtrace is:
SkydriveDocument<._createZpjEntry/<@resource:///org/gnome/Documents/js/documents.js:1179
main@resource:///org/gnome/Documents/js/main.js:47
run@resource:///org/gnome/gjs/modules/package.js:192
@/opt/bin/gnome-documents:6

So, it is libzapojit trying to talk to goa-daemon, which is using librest to do something that failed.

I don't know if it is up to libzapojit to strip the error or gnome-documents.
Comment 18 Debarshi Ray 2017-03-31 15:33:44 UTC
Created attachment 349060 [details] [review]
documents: Let everybody provide their own download implementation
Comment 19 Debarshi Ray 2017-03-31 15:33:58 UTC
Created attachment 349061 [details] [review]
documents: Strip the D-Bus error name from the UI string
Comment 20 Debarshi Ray 2017-03-31 15:34:13 UTC
(In reply to Cosimo Cecchi from comment #13)
> Review of attachment 349006 [details] [review] [review]:
> 
> ::: src/documents.js
> @@ +399,3 @@
> +                }));
> +        } else {
> +                        info = object.query_info_finish(res);
> 
> Nitpick: prefer checking for this case upfront and returning early.
> 
> @@ +423,3 @@
> +                             'Cannot set mtime on the cache file; cache
> will not be valid after the file has ' +
> +                             'been viewed.');
> +                    }
> 
> No semicolon needed here.

Fixed both.
Comment 21 Debarshi Ray 2017-03-31 15:35:37 UTC
Communication with OneDrive over the deprecated Live SDK implemented by libzapojit is still very flaky for me. It is ominous! We should port to the new MS Graph API as soon as possible.
Comment 22 Debarshi Ray 2017-03-31 18:46:09 UTC
Review of attachment 349008 [details] [review]:

accepted-commit_now -> reviewed:

::: src/documents.js
@@ +1265,3 @@
+                                        }
+
+                                        this.loadLocal(passwd, cancellable, callback);

We need to handle EvDocument.DocumentError.ENCRYPTED in case the PDF was encrypted. Would be nice if can avoid duplicating code between loading on the first and second attempts.
Comment 23 Cosimo Cecchi 2017-04-03 17:46:14 UTC
(In reply to Debarshi Ray from comment #16)
> However, I have a feeling that I misunderstood you. So, if this is not what
> you meant, could you expand a bit? :)

No, that makes sense. Looking forward to the PDF loader overhaul :-)
Comment 24 Cosimo Cecchi 2017-04-03 17:50:41 UTC
Review of attachment 349060 [details] [review]:

::: src/documents.js
@@ +395,3 @@
+                cacheMtime /= 1000000;
+
+                                   cancellable,

Instead of changing the mtime of the cache file to match the mtime of the original file, would it not be simpler to invalidate the cache when the mtime of the original file is newer than the one in the cache?
Comment 25 Cosimo Cecchi 2017-04-03 17:55:58 UTC
Review of attachment 349061 [details] [review]:

Not sure if it's up to gnome-documents to do this honestly. Libzapojit should probably have its own error domain and avoid forwarding raw dbus errors.
Comment 26 Debarshi Ray 2017-04-04 14:52:09 UTC
(In reply to Cosimo Cecchi from comment #24)
> Review of attachment 349060 [details] [review] [review]:
> 
> ::: src/documents.js
> @@ +395,3 @@
> +                cacheMtime /= 1000000;
> +
> +                                   cancellable,
> 
> Instead of changing the mtime of the cache file to match the mtime of the
> original file, would it not be simpler to invalidate the cache when the
> mtime of the original file is newer than the one in the cache?

Umm... what do you mean? You mean we should also delete the cached copy if it has gone stale?

The downloading / caching JavaScript code in this patch set is a close imitation of the similar C code in GdPdfLoader. Did I miss something?
Comment 27 Debarshi Ray 2017-04-04 15:20:01 UTC
(In reply to Debarshi Ray from comment #22)
> Review of attachment 349008 [details] [review] [review]:
> 
> accepted-commit_now -> reviewed:
> 
> ::: src/documents.js
> @@ +1265,3 @@
> +                                        }
> +
> +                                        this.loadLocal(passwd, cancellable,
> callback);
> 
> We need to handle EvDocument.DocumentError.ENCRYPTED in case the PDF was
> encrypted. Would be nice if can avoid duplicating code between loading on
> the first and second attempts.

Never mind. I was confused.

I managed to test this with an encrypted OneDrive PDF. There isn't anything to "handle" apart from passing an error to the callback. The only reason we "handle" it the first time is because we force a download if the cache was corrupted.

Restoring accepted-commit_now.
Comment 28 Debarshi Ray 2017-04-04 15:20:53 UTC
Review of attachment 349008 [details] [review]:

As per comment 27
Comment 29 Cosimo Cecchi 2017-04-04 16:35:47 UTC
(In reply to Debarshi Ray from comment #26)
> > Instead of changing the mtime of the cache file to match the mtime of the
> > original file, would it not be simpler to invalidate the cache when the
> > mtime of the original file is newer than the one in the cache?
> 
> Umm... what do you mean? You mean we should also delete the cached copy if
> it has gone stale?
> 
> The downloading / caching JavaScript code in this patch set is a close
> imitation of the similar C code in GdPdfLoader. Did I miss something?

I was just thinking out loud... Right now we set the mtime of the cache file to the mtime of the original file, and consider it invalid when they differ. We could instead leave the mtime of the cache file to when the cache file itself is created, and consider it invalid when the mtime of the original file is newer than the cache file's mtime.
Feel free to ignore this suggestion if you don't think it's a good idea :-)
Comment 30 Debarshi Ray 2017-04-04 17:21:25 UTC
(In reply to Cosimo Cecchi from comment #29)
> (In reply to Debarshi Ray from comment #26)
> > > Instead of changing the mtime of the cache file to match the mtime of the
> > > original file, would it not be simpler to invalidate the cache when the
> > > mtime of the original file is newer than the one in the cache?
> > 
> > Umm... what do you mean? You mean we should also delete the cached copy if
> > it has gone stale?
> > 
> > The downloading / caching JavaScript code in this patch set is a close
> > imitation of the similar C code in GdPdfLoader. Did I miss something?
> 
> I was just thinking out loud... Right now we set the mtime of the cache file
> to the mtime of the original file, and consider it invalid when they differ.
> We could instead leave the mtime of the cache file to when the cache file
> itself is created, and consider it invalid when the mtime of the original
> file is newer than the cache file's mtime.

Ok, I see. Sure.
Comment 31 Debarshi Ray 2017-04-04 17:32:29 UTC
Created attachment 349255 [details] [review]
documents: Let everybody provide their own download implementation
Comment 32 Debarshi Ray 2017-04-04 17:32:56 UTC
Created attachment 349256 [details] [review]
documents: Implement the downloadImpl vfunc for SkydriveDocument
Comment 33 Debarshi Ray 2017-04-05 14:16:15 UTC
Created attachment 349303 [details] [review]
documents, pdf-loader: Fix previewing of ODFs and OOXMLs on OneDrive

Also remove the unused GdPdfLoader code paths.
Comment 34 Cosimo Cecchi 2017-04-06 02:07:24 UTC
Review of attachment 349255 [details] [review]:

++
Comment 35 Cosimo Cecchi 2017-04-06 02:08:58 UTC
Review of attachment 349256 [details] [review]:

++
Comment 36 Cosimo Cecchi 2017-04-06 02:13:02 UTC
Review of attachment 349303 [details] [review]:

Looks good with one minor comment.

::: src/documents.js
@@ +1262,3 @@
+                                    }));
+                            } else {
+                                    function(fromCache, error) {

Can you fold this case into the first one, and turn the second one into if (fromCache && !error.matches(...))?
Comment 37 Debarshi Ray 2017-04-07 11:44:55 UTC
Created attachment 349461 [details] [review]
documents, pdf-loader: Fix previewing of ODFs and OOXMLs on OneDrive
Comment 38 Cosimo Cecchi 2017-04-07 18:01:34 UTC
Review of attachment 349461 [details] [review]:

Looks good!
Comment 39 Debarshi Ray 2017-04-08 12:59:18 UTC
Thanks for all the reviews, Cosimo!
Comment 40 Debarshi Ray 2017-04-20 09:58:38 UTC
Review of attachment 349255 [details] [review]:

::: src/documents.js
@@ +393,3 @@
+
+                let cacheMtime = info.get_attribute_uint64(Gio.FILE_ATTRIBUTE_TIME_MODIFIED);
+                cacheMtime /= 1000000;

Eek! Gio.FILE_ATTRIBUTE_TIME_MODIFIED returns a value in seconds, not microseconds.
Comment 41 Debarshi Ray 2017-04-20 09:58:50 UTC
Created attachment 350108 [details] [review]
documents: Fix the retrieval of the cache's modification time
Comment 42 Cosimo Cecchi 2017-04-20 16:17:18 UTC
Review of attachment 350108 [details] [review]:

Whoops, good catch!