Pārlūkot izejas kodu

fix: ensure app folder for every app action

Nicolas Meienberger 2 gadi atpakaļ
vecāks
revīzija
b7eb0d19de
1 mainītis faili ar 10 papildinājumiem un 2 dzēšanām
  1. 10 2
      packages/system-api/src/modules/apps/apps.service.ts

+ 10 - 2
packages/system-api/src/modules/apps/apps.service.ts

@@ -14,6 +14,7 @@ const startAllApps = async (): Promise<void> => {
     apps.map(async (app) => {
       // Regenerate env file
       try {
+        ensureAppFolder(app.id);
         generateEnvFile(app.id, app.config);
         checkEnvFile(app.id);
 
@@ -36,6 +37,8 @@ const startApp = async (appName: string): Promise<App> => {
     throw new Error(`App ${appName} not found`);
   }
 
+  ensureAppFolder(appName);
+
   // Regenerate env file
   generateEnvFile(appName, app.config);
 
@@ -57,13 +60,12 @@ const startApp = async (appName: string): Promise<App> => {
 };
 
 const installApp = async (id: string, form: Record<string, string>): Promise<App> => {
-  ensureAppFolder(id);
-
   let app = await App.findOne({ where: { id } });
 
   if (app) {
     await startApp(id);
   } else {
+    ensureAppFolder(id);
     const appIsValid = await checkAppRequirements(id);
 
     if (!appIsValid) {
@@ -135,6 +137,8 @@ const stopApp = async (id: string): Promise<App> => {
     throw new Error(`App ${id} not found`);
   }
 
+  ensureAppFolder(id);
+
   // Run script
   await App.update({ id }, { status: AppStatusEnum.STOPPING });
 
@@ -161,6 +165,8 @@ const uninstallApp = async (id: string): Promise<App> => {
     await stopApp(id);
   }
 
+  ensureAppFolder(id);
+
   await App.update({ id }, { status: AppStatusEnum.UNINSTALLING });
   // Run script
   try {
@@ -192,6 +198,8 @@ const updateApp = async (id: string) => {
     throw new Error(`App ${id} not found`);
   }
 
+  ensureAppFolder(id);
+
   await App.update({ id }, { status: AppStatusEnum.UPDATING });
 
   // Run script