@@ -185,16 +185,19 @@ func StopApp(ctx context.Context, app parser.App) iter.Seq[StreamMessage] {
185185 return
186186 }
187187 mainCompose := provisioningStateDir .Join ("app-compose.yaml" )
188- process , err := paths .NewProcess (nil , "docker" , "compose" , "-f" , mainCompose .String (), "stop" )
189- if err != nil {
190- yield (StreamMessage {error : err })
191- return
192- }
193- process .RedirectStderrTo (callbackWriter )
194- process .RedirectStdoutTo (callbackWriter )
195- if err := process .RunWithinContext (ctx ); err != nil {
196- yield (StreamMessage {error : err })
197- return
188+ // In case the app was never started
189+ if mainCompose .Exist () {
190+ process , err := paths .NewProcess (nil , "docker" , "compose" , "-f" , mainCompose .String (), "stop" )
191+ if err != nil {
192+ yield (StreamMessage {error : err })
193+ return
194+ }
195+ process .RedirectStderrTo (callbackWriter )
196+ process .RedirectStdoutTo (callbackWriter )
197+ if err := process .RunWithinContext (ctx ); err != nil {
198+ yield (StreamMessage {error : err })
199+ return
200+ }
198201 }
199202 }
200203 _ = yield (StreamMessage {progress : & Progress {Name : "" , Progress : 100.0 }})
@@ -479,6 +482,15 @@ func CloneApp(ctx context.Context, req CloneAppRequest) (response CloneAppRespon
479482 return CloneAppResponse {ID : id }, nil
480483}
481484
485+ func DeleteApp (ctx context.Context , app parser.App ) error {
486+ for msg := range StopApp (ctx , app ) {
487+ if msg .error != nil {
488+ return fmt .Errorf ("failed to stop app: %w" , msg .error )
489+ }
490+ }
491+ return app .FullPath .RemoveAll ()
492+ }
493+
482494func getCurrentUser () string {
483495 // MacOS and Windows uses a VM so we don't need to map the user.
484496 if runtime .GOOS == "darwin" || runtime .GOOS == "windows" {
0 commit comments