Explorar o código

await normalize processing

Yuki Takei %!s(int64=6) %!d(string=hai) anos
pai
achega
39f0f6772b
Modificáronse 1 ficheiros con 5 adicións e 5 borrados
  1. 5 5
      src/server/routes/apiv3/search.js

+ 5 - 5
src/server/routes/apiv3/search.js

@@ -89,16 +89,16 @@ module.exports = (crowi) => {
 
 
       switch (operation) {
       switch (operation) {
         case 'normalize':
         case 'normalize':
-          search.normalizeIndices();
-          break;
+          // wait the processing is terminated
+          await search.normalizeIndices();
+          return res.status(200).send({ message: 'Operation is successfully processed.' });
         case 'rebuild':
         case 'rebuild':
+          // NOT wait the processing is terminated
           search.buildIndex();
           search.buildIndex();
-          break;
+          return res.status(200).send({ message: 'Operation is successfully requested.' });
         default:
         default:
           throw new Error(`Unimplemented operation: ${operation}`);
           throw new Error(`Unimplemented operation: ${operation}`);
       }
       }
-
-      return res.status(200).send({ message: 'Operation is successfully requested.' });
     }
     }
     catch (err) {
     catch (err) {
       return res.apiv3Err(err);
       return res.apiv3Err(err);