ESourceRegistry: Ignore hidden files from .source folder monitoring
authorMilan Crha <mcrha@redhat.com>
Fri, 22 Nov 2013 15:53:44 +0000 (16:53 +0100)
committerMilan Crha <mcrha@redhat.com>
Fri, 22 Nov 2013 15:53:44 +0000 (16:53 +0100)
There used to be a critical warning on the source registry console:
   ** Failed to load key file at
   'file:///home/user/.config/evolution/sources/.goutputstream-1P9V6W':
   File must have a '.source' extension

There is nothing the source registry can do with these files (because
they are created by GIO), but ignore them during the folder monitoring,
instead of spreading useless runtime warning.

libebackend/e-server-side-source.c
libebackend/e-source-registry-server.c

index 686df0c..cbea9cd 100644 (file)
@@ -1428,7 +1428,9 @@ e_server_side_source_uid_from_file (GFile *file,
 
        basename = g_file_get_basename (file);
 
-       if (g_str_has_suffix (basename, ".source")) {
+       if (*basename == '.') {
+               /* ignore hidden files */
+       } else if (g_str_has_suffix (basename, ".source")) {
                /* strlen(".source") --> 7 */
                uid = g_strndup (basename, strlen (basename) - 7);
        } else {
index 562fd03..6d39142 100644 (file)
@@ -900,14 +900,10 @@ source_registry_server_monitor_changed_cb (GFileMonitor *monitor,
                ESource *source;
                GError *error = NULL;
 
+               /* it can return NULL source for hidden files */
                source = e_server_side_source_new (server, file, &error);
 
-               /* Sanity check. */
-               g_return_if_fail (
-                       ((source != NULL) && (error == NULL)) ||
-                       ((source == NULL) && (error != NULL)));
-
-               if (error == NULL) {
+               if (!error && source) {
                        /* File monitors are only placed on directories
                         * where data sources are writable and removable,
                         * so it should be safe to assume these flags. */
@@ -918,7 +914,7 @@ source_registry_server_monitor_changed_cb (GFileMonitor *monitor,
 
                        e_source_registry_server_add_source (server, source);
                        g_object_unref (source);
-               } else {
+               } else if (error) {
                        e_source_registry_server_load_error (
                                server, file, error);
                        g_error_free (error);