Auto-creation of host-paths has been un-deprecated,
so to have feature-parity between Linux and Windows,
this feature should also be present on Windows.
This enables auto-creation on Windows.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -3,10 +3,10 @@ package volume |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"os" |
| 6 |
- "runtime" |
|
| 7 | 6 |
"strings" |
| 8 | 7 |
|
| 9 | 8 |
"github.com/docker/docker/pkg/stringid" |
| 9 |
+ "github.com/docker/docker/pkg/system" |
|
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
// DefaultDriverName is the driver name used for the driver |
| ... | ... |
@@ -80,20 +80,20 @@ func (m *MountPoint) Setup() (string, error) {
|
| 80 | 80 |
} |
| 81 | 81 |
return m.Volume.Mount(m.ID) |
| 82 | 82 |
} |
| 83 |
- if len(m.Source) > 0 {
|
|
| 84 |
- if _, err := os.Stat(m.Source); err != nil {
|
|
| 85 |
- if !os.IsNotExist(err) {
|
|
| 86 |
- return "", err |
|
| 87 |
- } |
|
| 88 |
- if runtime.GOOS != "windows" { // Windows does not have deprecation issues here
|
|
| 89 |
- if err := os.MkdirAll(m.Source, 0755); err != nil {
|
|
| 90 |
- return "", err |
|
| 91 |
- } |
|
| 92 |
- } |
|
| 83 |
+ if len(m.Source) == 0 {
|
|
| 84 |
+ return "", fmt.Errorf("Unable to setup mount point, neither source nor volume defined")
|
|
| 85 |
+ } |
|
| 86 |
+ // system.MkdirAll() produces an error if m.Source exists and is a file (not a directory), |
|
| 87 |
+ // so first check if the path does not exist |
|
| 88 |
+ if _, err := os.Stat(m.Source); err != nil {
|
|
| 89 |
+ if !os.IsNotExist(err) {
|
|
| 90 |
+ return "", err |
|
| 91 |
+ } |
|
| 92 |
+ if err := system.MkdirAll(m.Source, 0755); err != nil {
|
|
| 93 |
+ return "", err |
|
| 93 | 94 |
} |
| 94 |
- return m.Source, nil |
|
| 95 | 95 |
} |
| 96 |
- return "", fmt.Errorf("Unable to setup mount point, neither source nor volume defined")
|
|
| 96 |
+ return m.Source, nil |
|
| 97 | 97 |
} |
| 98 | 98 |
|
| 99 | 99 |
// Path returns the path of a volume in a mount point. |