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:
@@ -123,6 +123,19 @@ func CorePostDeploy(input CorePostDeployInput) error {
|
|||||||
return fmt.Errorf("Missing required Destination in CorePostDeploy for plugin %v", input.PluginName)
|
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 {
|
for i, extractedPath := range input.ExtractedPaths {
|
||||||
if extractedPath.Path == "" {
|
if extractedPath.Path == "" {
|
||||||
return fmt.Errorf("Missing required Name in CorePostDeploy for index %v for plugin %v", i, input.PluginName)
|
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()
|
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 {
|
for i, toExtract := range input.ToExtract {
|
||||||
if toExtract.Name == "" {
|
if toExtract.Name == "" {
|
||||||
return fmt.Errorf("Name is required for index %v in CorePostExtract for plugin %v", i, input.PluginName)
|
return fmt.Errorf("Name is required for index %v in CorePostExtract for plugin %v", i, input.PluginName)
|
||||||
|
|||||||
Reference in New Issue
Block a user