diff --git a/plugins/ps/functions.go b/plugins/ps/functions.go index 9b08842b7..36810de03 100644 --- a/plugins/ps/functions.go +++ b/plugins/ps/functions.go @@ -52,10 +52,14 @@ func extractProcfile(appName, image string, procfilePath string) error { func extractOrGenerateScalefile(appName string, image string) error { destination := getScalefilePath(appName) extracted := getScalefileExtractedPath(appName) - if err := common.CopyFromImage(appName, image, "DOKKU_SCALE", destination); err != nil { + previouslyExtracted := common.FileExists(extracted) + + if err := common.CopyFromImage(appName, image, "DOKKU_SCALE", extracted); err != nil { + if previouslyExtracted { + os.Remove(destination) + } os.Remove(extracted) - os.Remove(destination) - } else if err := common.CopyFile(destination, extracted); err != nil { + } else if err := common.CopyFile(extracted, destination); err != nil { return err } diff --git a/plugins/ps/triggers.go b/plugins/ps/triggers.go index 8f9047941..d08558f1d 100644 --- a/plugins/ps/triggers.go +++ b/plugins/ps/triggers.go @@ -132,6 +132,7 @@ func TriggerPreDeploy(appName string, imageTag string) error { if err := extractProcfile(appName, image, procfilePath); err != nil { return err } + if err := extractOrGenerateScalefile(appName, imageTag); err != nil { return err }