|
@@ -26,7 +26,7 @@ const debug = require('debug')('growi:services:page');
|
|
|
|
|
|
|
|
const logger = loggerFactory('growi:services:page');
|
|
const logger = loggerFactory('growi:services:page');
|
|
|
const {
|
|
const {
|
|
|
- isCreatablePage, isTrashPage, collectAncestorPaths, isTopPage,
|
|
|
|
|
|
|
+ isCreatablePage, isTrashPage, isTopPage, omitDuplicateAreaPathFromPaths,
|
|
|
} = pagePathUtils;
|
|
} = pagePathUtils;
|
|
|
|
|
|
|
|
const BULK_REINDEX_SIZE = 100;
|
|
const BULK_REINDEX_SIZE = 100;
|
|
@@ -1845,8 +1845,28 @@ class PageService {
|
|
|
// socket.emit('normalizeParentRecursivelyByPageIds', { error: err.message }); TODO: use socket to tell user
|
|
// socket.emit('normalizeParentRecursivelyByPageIds', { error: err.message }); TODO: use socket to tell user
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // generate regexps
|
|
|
|
|
- const regexps = await this._generateRegExpsByPageIds(normalizedIds);
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ * generate regexps
|
|
|
|
|
+ */
|
|
|
|
|
+ const Page = mongoose.model('Page') as unknown as PageModel;
|
|
|
|
|
+
|
|
|
|
|
+ let result;
|
|
|
|
|
+ try {
|
|
|
|
|
+ result = await Page.findListByPageIds(pageIds, null, false);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (err) {
|
|
|
|
|
+ logger.error('Failed to find pages by ids', err);
|
|
|
|
|
+ throw err;
|
|
|
|
|
+ }
|
|
|
|
|
+ const { pages } = result;
|
|
|
|
|
+
|
|
|
|
|
+ // prepare no duplicated area paths
|
|
|
|
|
+ let paths = pages.map(p => p.path);
|
|
|
|
|
+ paths = omitDuplicateAreaPathFromPaths(paths);
|
|
|
|
|
+
|
|
|
|
|
+ const regexps = paths.map(path => new RegExp(`^${escapeStringRegexp(path)}`));
|
|
|
|
|
+
|
|
|
|
|
+ // TODO: insertMany PageOperationBlock
|
|
|
|
|
|
|
|
// migrate recursively
|
|
// migrate recursively
|
|
|
try {
|
|
try {
|
|
@@ -1940,27 +1960,6 @@ class PageService {
|
|
|
await this._setIsV5CompatibleTrue();
|
|
await this._setIsV5CompatibleTrue();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- * returns an array of js RegExp instance instead of RE2 instance for mongo filter
|
|
|
|
|
- */
|
|
|
|
|
- private async _generateRegExpsByPageIds(pageIds) {
|
|
|
|
|
- const Page = mongoose.model('Page') as unknown as PageModel;
|
|
|
|
|
-
|
|
|
|
|
- let result;
|
|
|
|
|
- try {
|
|
|
|
|
- result = await Page.findListByPageIds(pageIds, null);
|
|
|
|
|
- }
|
|
|
|
|
- catch (err) {
|
|
|
|
|
- logger.error('Failed to find pages by ids', err);
|
|
|
|
|
- throw err;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const { pages } = result;
|
|
|
|
|
- const regexps = pages.map(page => new RegExp(`^${escapeStringRegexp(page.path)}`));
|
|
|
|
|
-
|
|
|
|
|
- return regexps;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private async _setIsV5CompatibleTrue() {
|
|
private async _setIsV5CompatibleTrue() {
|
|
|
try {
|
|
try {
|
|
|
await this.crowi.configManager.updateConfigsInTheSameNamespace('crowi', {
|
|
await this.crowi.configManager.updateConfigsInTheSameNamespace('crowi', {
|