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 748896 - src: Try all GrlSources in grl_multiple_get_media_from_uri()
src: Try all GrlSources in grl_multiple_get_media_from_uri()
Status: RESOLVED FIXED
Product: grilo
Classification: Other
Component: core
unspecified
Other All
: Normal normal
: ---
Assigned To: grilo-maint
grilo-maint
Depends on:
Blocks:
 
 
Reported: 2015-05-04 14:47 UTC by Philip Withnall
Modified: 2015-06-16 11:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
src: Try all GrlSources in grl_multiple_get_media_from_uri() (5.35 KB, patch)
2015-05-04 14:47 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2015-05-04 14:47:15 UTC
See the commit message for reasoning: grl_multiple_get_media_from_uri() can fail if a GrlSource says it can get a GrlMedia for a URI, but then returns NULL.
Comment 1 Philip Withnall 2015-05-04 14:47:18 UTC
Created attachment 302868 [details] [review]
src: Try all GrlSources in grl_multiple_get_media_from_uri()

Previously, grl_multiple_get_media_from_uri() would stop as soon as
a source returned TRUE for grl_source_test_media_from_uri() but then
returned a NULL GrlMedia in its grl_source_get_media_from_uri()
callback.

That’s probably not what the user wanted, so instead continue to
asynchronously try the remaining GrlSources until a GrlMedia is returned
or the end of the sources list is reached.
Comment 2 Bastien Nocera 2015-05-07 13:25:01 UTC
(In reply to Philip Withnall from comment #1)
> Created attachment 302868 [details] [review] [review]
> src: Try all GrlSources in grl_multiple_get_media_from_uri()
> 
> Previously, grl_multiple_get_media_from_uri() would stop as soon as
> a source returned TRUE for grl_source_test_media_from_uri() but then
> returned a NULL GrlMedia in its grl_source_get_media_from_uri()
> callback.

Do we have any sources in grilo-plugins that would behave like that? Any chance you could add a test for that case in grilo-plugins as well?

> That’s probably not what the user wanted, so instead continue to
> asynchronously try the remaining GrlSources until a GrlMedia is returned
> or the end of the sources list is reached.

That seems like the correct behaviour, but now it never returns an error. Should the first error be remembered and sent?
Comment 3 Bastien Nocera 2015-05-07 13:25:22 UTC
Review of attachment 302868 [details] [review]:

Marking as needs-work as per comment.
Comment 4 Philip Withnall 2015-05-11 07:14:47 UTC
(In reply to Bastien Nocera from comment #2)
> (In reply to Philip Withnall from comment #1)
> > Created attachment 302868 [details] [review] [review] [review]
> > src: Try all GrlSources in grl_multiple_get_media_from_uri()
> > 
> > Previously, grl_multiple_get_media_from_uri() would stop as soon as
> > a source returned TRUE for grl_source_test_media_from_uri() but then
> > returned a NULL GrlMedia in its grl_source_get_media_from_uri()
> > callback.
> 
> Do we have any sources in grilo-plugins that would behave like that?

I can't prove it, but I suspect the Tracker plugin.

> Any chance you could add a test for that case in grilo-plugins as well?

Will do.

> > That’s probably not what the user wanted, so instead continue to
> > asynchronously try the remaining GrlSources until a GrlMedia is returned
> > or the end of the sources list is reached.
> 
> That seems like the correct behaviour, but now it never returns an error.
> Should the first error be remembered and sent?

I don't know; I thought about it, but I can't think of any particularly good reason for reporting the first error, or reporting no errors.
Comment 5 Bastien Nocera 2015-05-11 09:09:52 UTC
(In reply to Philip Withnall from comment #4)
> (In reply to Bastien Nocera from comment #2)
> > (In reply to Philip Withnall from comment #1)
> > > That’s probably not what the user wanted, so instead continue to
> > > asynchronously try the remaining GrlSources until a GrlMedia is returned
> > > or the end of the sources list is reached.
> > 
> > That seems like the correct behaviour, but now it never returns an error.
> > Should the first error be remembered and sent?
> 
> I don't know; I thought about it, but I can't think of any particularly good
> reason for reporting the first error, or reporting no errors.

I'd rather it reported the first error if every call failed.
Comment 6 Philip Withnall 2015-06-10 10:59:45 UTC
(In reply to Philip Withnall from comment #4)
> (In reply to Bastien Nocera from comment #2)
> > (In reply to Philip Withnall from comment #1)
> > > Created attachment 302868 [details] [review] [review] [review] [review]
> > > src: Try all GrlSources in grl_multiple_get_media_from_uri()
> > > 
> > > Previously, grl_multiple_get_media_from_uri() would stop as soon as
> > > a source returned TRUE for grl_source_test_media_from_uri() but then
> > > returned a NULL GrlMedia in its grl_source_get_media_from_uri()
> > > callback.
> > 
> > Do we have any sources in grilo-plugins that would behave like that?
> 
> I can't prove it, but I suspect the Tracker plugin.
> 
> > Any chance you could add a test for that case in grilo-plugins as well?
> 
> Will do.

So since the problem is in the Tracker plugin, and testing that is a nightmare (there are no existing unit tests for it, no test framework, and a huge amount of harness state to set up), I don’t think I can write a test for this.

(In reply to Bastien Nocera from comment #5)
> (In reply to Philip Withnall from comment #4)
> > (In reply to Bastien Nocera from comment #2)
> > > (In reply to Philip Withnall from comment #1)
> > > > That’s probably not what the user wanted, so instead continue to
> > > > asynchronously try the remaining GrlSources until a GrlMedia is returned
> > > > or the end of the sources list is reached.
> > > 
> > > That seems like the correct behaviour, but now it never returns an error.
> > > Should the first error be remembered and sent?
> > 
> > I don't know; I thought about it, but I can't think of any particularly good
> > reason for reporting the first error, or reporting no errors.
> 
> I'd rather it reported the first error if every call failed.

The patch currently reports a GRL_CORE_ERROR_MEDIA_FROM_URI_FAILED error if it gets to the end of the GrlSources list and hasn’t found a result. I think this makes as much sense as reporting the first resolution error.
Comment 7 Bastien Nocera 2015-06-16 10:51:44 UTC
Comment on attachment 302868 [details] [review]
src: Try all GrlSources in grl_multiple_get_media_from_uri()

Marking as a-c-n as per discussion.
Comment 8 Philip Withnall 2015-06-16 11:34:18 UTC
Cheers.

Attachment 302868 [details] pushed as 179e6c3 - src: Try all GrlSources in grl_multiple_get_media_from_uri()