]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/spotlight.c
Spotlight: move init to the right place
[netatalk.git] / etc / afpd / spotlight.c
index 3755e41d1326d9d289da5ef90ea0ecbff1b8d8b8..7551bc7174f1ed2b655fb6d664e06ce7c5f6f02c 100644 (file)
@@ -1192,9 +1192,14 @@ EC_CLEANUP:
 
 int spotlight_init(AFPObj *obj)
 {
+    static bool initialized = false;
     const char *attributes;
     struct sl_ctx *sl_ctx;
 
+    if (initialized) {
+        return 0;
+    }
+
     LOG(log_info, logtype_sl, "Initializing Spotlight");
 
     sl_ctx = talloc_zero(NULL, struct sl_ctx);
@@ -1220,6 +1225,7 @@ int spotlight_init(AFPObj *obj)
     tracker_sparql_connection_get_async(sl_ctx->cancellable,
                                         tracker_con_cb, sl_ctx);
 
+    initialized = true;
     return 0;
 }
 
@@ -1247,6 +1253,8 @@ int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen,
         return AFPERR_NOOP;
     }
 
+    spotlight_init(obj);
+
     /*
      * Process finished glib events
      */