Преглед изворни кода

fix #92 初回アクセス時に「TypeError: Cannot read property 'buildIndex' of null」が出力されます

Yuki Takei пре 8 година
родитељ
комит
76f32a7424
1 измењених фајлова са 11 додато и 8 уклоњено
  1. 11 8
      lib/util/middlewares.js

+ 11 - 8
lib/util/middlewares.js

@@ -261,15 +261,18 @@ exports.applicationNotInstalled = function() {
 
 
 exports.checkSearchIndicesGenerated = function(crowi, app) {
 exports.checkSearchIndicesGenerated = function(crowi, app) {
   return function(req, res, next) {
   return function(req, res, next) {
-    // build index
     const searcher = crowi.getSearcher();
     const searcher = crowi.getSearcher();
-    searcher.buildIndex()
-      .then((data) => {
-        if (!data.errors) {
-          debug('Index created.');
-        }
-        return searcher.addAllPages();
-      });
+
+    // build index
+    if (searcher) {
+      searcher.buildIndex()
+        .then((data) => {
+          if (!data.errors) {
+            debug('Index created.');
+          }
+          return searcher.addAllPages();
+        });
+    }
 
 
     return next();
     return next();
   };
   };