Parcourir la source

Merge pull request #3276 from weseek/imprv/reduce-only-delete-action

reduce load of delete(rename)
Yuki Takei il y a 5 ans
Parent
commit
4726bc872d
1 fichiers modifiés avec 6 ajouts et 7 suppressions
  1. 6 7
      src/server/models/page.js

+ 6 - 7
src/server/models/page.js

@@ -1128,17 +1128,16 @@ module.exports = function(crowi) {
 
   pageSchema.statics.deletePageRecursively = async function(targetPage, user, options = {}) {
     const isTrashed = checkIfTrashed(targetPage.path);
-
+    const newPath = this.getDeletedPageName(targetPage.path);
     if (isTrashed) {
       throw new Error('This method does NOT supports deleting trashed pages.');
     }
 
-    // find manageable descendants (this array does not include GRANT_RESTRICTED)
-    const pages = await this.findManageableListWithDescendants(targetPage, user, options);
-
-    await Promise.all(pages.map((page) => {
-      return this.deletePage(page, user, options);
-    }));
+    const socketClientId = options.socketClientId || null;
+    if (this.isDeletableName(targetPage.path)) {
+      targetPage.status = STATUS_DELETED;
+    }
+    return await this.renameRecursively(targetPage, newPath, user, { socketClientId, createRedirectPage: true });
   };