Ver Fonte

fix: ensure app folder for every app action

Nicolas Meienberger há 2 anos atrás
pai
commit
b7eb0d19de
1 ficheiros alterados com 10 adições e 2 exclusões
  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) => {
     apps.map(async (app) => {
       // Regenerate env file
       // Regenerate env file
       try {
       try {
+        ensureAppFolder(app.id);
         generateEnvFile(app.id, app.config);
         generateEnvFile(app.id, app.config);
         checkEnvFile(app.id);
         checkEnvFile(app.id);
 
 
@@ -36,6 +37,8 @@ const startApp = async (appName: string): Promise<App> => {
     throw new Error(`App ${appName} not found`);
     throw new Error(`App ${appName} not found`);
   }
   }
 
 
+  ensureAppFolder(appName);
+
   // Regenerate env file
   // Regenerate env file
   generateEnvFile(appName, app.config);
   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> => {
 const installApp = async (id: string, form: Record<string, string>): Promise<App> => {
-  ensureAppFolder(id);
-
   let app = await App.findOne({ where: { id } });
   let app = await App.findOne({ where: { id } });
 
 
   if (app) {
   if (app) {
     await startApp(id);
     await startApp(id);
   } else {
   } else {
+    ensureAppFolder(id);
     const appIsValid = await checkAppRequirements(id);
     const appIsValid = await checkAppRequirements(id);
 
 
     if (!appIsValid) {
     if (!appIsValid) {
@@ -135,6 +137,8 @@ const stopApp = async (id: string): Promise<App> => {
     throw new Error(`App ${id} not found`);
     throw new Error(`App ${id} not found`);
   }
   }
 
 
+  ensureAppFolder(id);
+
   // Run script
   // Run script
   await App.update({ id }, { status: AppStatusEnum.STOPPING });
   await App.update({ id }, { status: AppStatusEnum.STOPPING });
 
 
@@ -161,6 +165,8 @@ const uninstallApp = async (id: string): Promise<App> => {
     await stopApp(id);
     await stopApp(id);
   }
   }
 
 
+  ensureAppFolder(id);
+
   await App.update({ id }, { status: AppStatusEnum.UNINSTALLING });
   await App.update({ id }, { status: AppStatusEnum.UNINSTALLING });
   // Run script
   // Run script
   try {
   try {
@@ -192,6 +198,8 @@ const updateApp = async (id: string) => {
     throw new Error(`App ${id} not found`);
     throw new Error(`App ${id} not found`);
   }
   }
 
 
+  ensureAppFolder(id);
+
   await App.update({ id }, { status: AppStatusEnum.UPDATING });
   await App.update({ id }, { status: AppStatusEnum.UPDATING });
 
 
   // Run script
   // Run script