瀏覽代碼

add errorhandling to deletePlugin function

NaokiHigashi28 1 年之前
父節點
當前提交
71bef31d72
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      apps/app/src/features/growi-plugin/server/services/growi-plugin/growi-plugin.ts

+ 9 - 1
apps/app/src/features/growi-plugin/server/services/growi-plugin/growi-plugin.ts

@@ -315,8 +315,16 @@ export class GrowiPluginService implements IGrowiPluginService {
       throw new Error('No plugin found for this ID.');
     }
 
+    let growiPluginsPath: fs.PathLike | undefined;
+    try {
+      growiPluginsPath = this.joinAndValidatePath(PLUGIN_STORING_PATH, growiPlugins.installedPath);
+    }
+    catch (err) {
+      logger.error(err);
+      throw new Error('Failed to constract plugin path');
+    }
+
     try {
-      const growiPluginsPath = path.join(PLUGIN_STORING_PATH, growiPlugins.installedPath);
       await deleteFolder(growiPluginsPath);
     }
     catch (err) {