Ver Fonte

add exception

yohei0125 há 4 anos atrás
pai
commit
5e21e373b0
1 ficheiros alterados com 5 adições e 0 exclusões
  1. 5 0
      packages/app/src/server/service/page.ts

+ 5 - 0
packages/app/src/server/service/page.ts

@@ -665,6 +665,11 @@ class PageService {
    * Duplicate
    */
   async duplicate(page, newPagePath, user, isRecursively) {
+    const isEmptyAndNotRecursively = page?.isEmpty && !isRecursively;
+    if (page == null || isEmptyAndNotRecursively) {
+      throw new Error('Cannot find or duplicate the empty page');
+    }
+
     const Page = mongoose.model('Page') as unknown as PageModel;
     const PageTagRelation = mongoose.model('PageTagRelation') as any; // TODO: Typescriptize model