Merge pull request #8273 from dokku/8272-fix-missing-directory

Ensure the destination directory exists when extracting files from a repository
This commit is contained in:
Jose Diaz-Gonzalez
2026-01-10 01:46:11 -05:00
committed by GitHub

View File

@@ -123,6 +123,19 @@ func CorePostDeploy(input CorePostDeployInput) error {
return fmt.Errorf("Missing required Destination in CorePostDeploy for plugin %v", input.PluginName)
}
if !DirectoryExists(input.Destination) {
if err := os.MkdirAll(input.Destination, 0755); err != nil {
return fmt.Errorf("Unable to create destination directory %v: %s", input.Destination, err.Error())
}
if err := SetPermissions(SetPermissionInput{
Filename: input.Destination,
Mode: 0755,
}); err != nil {
return fmt.Errorf("Unable to set destination directory permissions %v: %s", input.Destination, err.Error())
}
}
for i, extractedPath := range input.ExtractedPaths {
if extractedPath.Path == "" {
return fmt.Errorf("Missing required Name in CorePostDeploy for index %v for plugin %v", i, input.PluginName)
@@ -250,6 +263,19 @@ func CorePostExtract(input CorePostExtractInput) error {
})
sourceImage := results.StdoutContents()
if !DirectoryExists(input.Destination) {
if err := os.MkdirAll(input.Destination, 0755); err != nil {
return fmt.Errorf("Unable to create destination directory %v: %s", input.Destination, err.Error())
}
if err := SetPermissions(SetPermissionInput{
Filename: input.Destination,
Mode: 0755,
}); err != nil {
return fmt.Errorf("Unable to set destination directory permissions %v: %s", input.Destination, err.Error())
}
}
for i, toExtract := range input.ToExtract {
if toExtract.Name == "" {
return fmt.Errorf("Name is required for index %v in CorePostExtract for plugin %v", i, input.PluginName)