itizawa пре 5 година
родитељ
комит
f99885d00e
1 измењених фајлова са 6 додато и 4 уклоњено
  1. 6 4
      src/server/service/page.js

+ 6 - 4
src/server/service/page.js

@@ -311,14 +311,16 @@ class PageService {
       // e.g. page.path = /trash/test, toPath = /test
       // e.g. page.path = /trash/test, toPath = /test
       const toPath = Page.getRevertDeletedPageName(page.path);
       const toPath = Page.getRevertDeletedPageName(page.path);
 
 
+      if (pathRedirectToMapping[toPath] != null) {
       // When the page is deleted, it will always be created with "redirectTo" in the path of the original page.
       // When the page is deleted, it will always be created with "redirectTo" in the path of the original page.
       // So, it's ok to delete the page
       // So, it's ok to delete the page
       // However, If a page exists that is not "redirectTo", something is wrong. (Data correction is needed).
       // However, If a page exists that is not "redirectTo", something is wrong. (Data correction is needed).
-      if (pathRedirectToMapping[toPath] === page.path) {
-        removePageBulkOp.find({ path: toPath, redirectTo: page.path }).remove();
-        revertPageBulkOp.find({ _id: page._id }).update({ $set: { path: toPath, status: STATUS_PUBLISHED, lastUpdateUser: user._id } });
-        revertRevisionBulkOp.find({ path: page.path }).update({ $set: { path: toPath } }, { multi: true });
+        if (pathRedirectToMapping[toPath] === page.path) {
+          removePageBulkOp.find({ path: toPath, redirectTo: page.path }).remove();
+        }
       }
       }
+      revertPageBulkOp.find({ _id: page._id }).update({ $set: { path: toPath, status: STATUS_PUBLISHED, lastUpdateUser: user._id } });
+      revertRevisionBulkOp.find({ path: page.path }).update({ $set: { path: toPath } }, { multi: true });
     });
     });
 
 
     try {
     try {