[grilo-plugins] filesystem: Better error message when browsing fails



commit 9abd83d641465283a31472772e91db4ead2f96e0
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Feb 19 10:38:14 2014 +0100

    filesystem: Better error message when browsing fails
    
    We try to keep the original error domain and code, so that
    interested front-ends can act upon the errors. For example,
    a G_IO_ERROR/G_IO_ERROR_NOT_MOUNTED error could trigger something
    to mount the item.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=725203

 src/filesystem/grl-filesystem.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/filesystem/grl-filesystem.c b/src/filesystem/grl-filesystem.c
index 4d6f6bc..915a795 100644
--- a/src/filesystem/grl-filesystem.c
+++ b/src/filesystem/grl-filesystem.c
@@ -1112,7 +1112,9 @@ grl_filesystem_source_resolve (GrlSource *source,
 {
   GFile *file;
   const gchar *id;
+  GFileInfo *info;
   GList *chosen_uris;
+  GError *error = NULL;
 
   GRL_DEBUG (__FUNCTION__);
 
@@ -1135,15 +1137,18 @@ grl_filesystem_source_resolve (GrlSource *source,
     file = g_file_new_for_uri (id ? id : DEFAULT_ROOT);
   }
 
-  if (g_file_query_exists (file, NULL)) {
+  info = g_file_query_info (file, "", G_FILE_QUERY_INFO_NONE, NULL, &error);
+  if (info != NULL) {
     grl_pls_file_to_media (rs->media, file, NULL, GRL_FILESYSTEM_SOURCE(source)->priv->handle_pls, 
rs->options);
     rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL);
+    g_object_unref (info);
   } else {
-    GError *error = g_error_new (GRL_CORE_ERROR,
-                                 GRL_CORE_ERROR_RESOLVE_FAILED,
-                                 _("File %s does not exist"),
-                                 id);
-    rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, error);
+    GError *error_new = g_error_new (error->domain,
+                                     error->code,
+                                     _("File %s does not exist"),
+                                     id);
+    rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, error_new);
+    g_error_free (error_new);
     g_error_free (error);
   }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]