Merge pull request #23731 from twangboy/fix_22959

Fixes #22959: Trying to add a directory to an unmapped drive in windows
This commit is contained in:
Thomas S Hatch 2015-05-14 15:59:13 -06:00
commit 72cf360255

View file

@ -1675,6 +1675,14 @@ def directory(name,
if not os.path.isdir(os.path.dirname(name)):
# The parent directory does not exist, create them
if makedirs:
# Make sure the drive is mapped before trying to create the
# path in windows
if salt.utils.is_windows():
drive, path = os.path.splitdrive(name)
if not os.path.isdir(drive):
return _error(
ret, 'Drive {0} is not mapped'.format(drive))
# Everything's good, create the path
__salt__['file.makedirs'](
name, user=user, group=group, mode=dir_mode
)