Przeglądaj źródła

PAGE_EXPIRATION_SECONDS -> WIP_PAGE_EXPIRATION_SECONDS

Shun Miyazawa 2 lat temu
rodzic
commit
7ac3742768

+ 2 - 2
apps/app/src/server/service/config-loader.ts

@@ -711,9 +711,9 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
     type: ValueType.NUMBER,
     default: 30000,
   },
-  PAGE_EXPIRATION_SECONDS: {
+  WIP_PAGE_EXPIRATION_SECONDS: {
     ns: 'crowi',
-    key: 'app:pageExpirationSeconds',
+    key: 'app:wipPageExpirationSeconds',
     type: ValueType.NUMBER,
     default: 172800, // 2 days
   },

+ 5 - 4
apps/app/src/server/service/page/index.ts

@@ -3850,7 +3850,6 @@ class PageService implements IPageService {
       throw err;
     }
 
-    this.disableAncestorPagesTtl(path);
     this.createSubOperation(savedPage, user, options, pageOp._id);
 
     return savedPage;
@@ -3860,6 +3859,8 @@ class PageService implements IPageService {
    * Used to run sub operation in create method
    */
   async createSubOperation(page, user, options: IOptionsForCreate, pageOpId: ObjectIdLike): Promise<void> {
+    await this.disableAncestorPagesTtl(page.path);
+
     // Update descendantCount
     await this.updateDescendantCountOfAncestors(page._id, 1, false);
 
@@ -4429,7 +4430,7 @@ class PageService implements IPageService {
   }
 
   async createTtlIndex(): Promise<void> {
-    const pageExpirationSeconds = configManager.getConfig('crowi', 'app:pageExpirationSeconds') ?? 172800;
+    const wipPageExpirationSeconds = configManager.getConfig('crowi', 'app:wipPageExpirationSeconds') ?? 172800;
     const collection = mongoose.connection.collection('pages');
 
     try {
@@ -4438,7 +4439,7 @@ class PageService implements IPageService {
       const indexes = await collection.indexes();
       const foundTargetField = indexes.find(i => i.name === targetField);
 
-      const isNotSpec = foundTargetField?.expireAfterSeconds == null || foundTargetField?.expireAfterSeconds !== pageExpirationSeconds;
+      const isNotSpec = foundTargetField?.expireAfterSeconds == null || foundTargetField?.expireAfterSeconds !== wipPageExpirationSeconds;
       const shoudDropIndex = foundTargetField != null && isNotSpec;
       const shoudCreateIndex = foundTargetField == null || shoudDropIndex;
 
@@ -4447,7 +4448,7 @@ class PageService implements IPageService {
       }
 
       if (shoudCreateIndex) {
-        await collection.createIndex({ ttlTimestamp: 1 }, { expireAfterSeconds: pageExpirationSeconds });
+        await collection.createIndex({ ttlTimestamp: 1 }, { expireAfterSeconds: wipPageExpirationSeconds });
       }
     }
     catch (err) {