Taichi Masuyama 4 лет назад
Родитель
Сommit
3bdf24800f

+ 0 - 6
packages/app/src/server/service/config-loader.ts

@@ -172,12 +172,6 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
     type:    ValueType.BOOLEAN,
     default: false,
   },
-  IS_V5_INDEX_NORMALIZATION_IN_PROGRESS: {
-    ns:      'crowi',
-    key:     'app:isV5IndexNormalizationInProgress',
-    type:    ValueType.BOOLEAN,
-    default: false,
-  },
   IS_V5_COMPATIBLE: {
     ns:      'crowi',
     key:     'app:isV5Compatible',

+ 2 - 21
packages/app/src/server/service/page.js

@@ -865,18 +865,6 @@ class PageService {
     }
   }
 
-  async _setIsV5IndexNormalizationInProgress(status) {
-    try {
-      await this.crowi.configManager.updateConfigsInTheSameNamespace('crowi', {
-        'app:isV5IndexNormalizationInProgress': status,
-      });
-    }
-    catch (err) {
-      logger.error(`Failed to update app:isV5IndexNormalizationInProgress to ${status} .`);
-      throw err;
-    }
-  }
-
   async _isPagePathIndexUnique() {
     const Page = this.crowi.model('Page');
     const now = (new Date()).toString();
@@ -897,6 +885,7 @@ class PageService {
       }
       else {
         logger.error('Error occurred while checking index uniqueness.', err);
+        await Page.deleteMany({ path: { $regex: new RegExp('growi_check_is_path_index_unique', 'g') } });
         throw err;
       }
     }
@@ -906,28 +895,20 @@ class PageService {
     return isUnique;
   }
 
+  // TODO: use socket to send status to the client
   async v5InitialMigration(grant) {
     // const socket = this.crowi.socketIoService.getAdminSocket();
-    const isProcessing = this.crowi.configManager.getConfig('crowi', 'app:isV5IndexNormalizationInProgress');
-
-    // avoid re-running many times
-    if (isProcessing) {
-      return;
-    }
 
     const isUnique = await this._isPagePathIndexUnique();
 
     // drop unique index first
     if (isUnique) {
-      await this._setIsV5IndexNormalizationInProgress(true);
       try {
         await this._v5NormalizeIndex();
-        await this._setIsV5IndexNormalizationInProgress(false);
       }
       catch (err) {
         logger.error('V5 index normalization failed.', err);
         // socket.emit('v5IndexNormalizationFailed', { error: err.message });
-        await this._setIsV5IndexNormalizationInProgress(false);
         throw err;
       }
     }