Fixes #22959: Trying to add a directory to an unmapped drive in windows

This commit is contained in:
twangboy 2015-05-14 17:20:57 +00:00
parent 3e9df883d6
commit 88e5495b2d

View File

@ -1675,6 +1675,14 @@ def directory(name,
if not os.path.isdir(os.path.dirname(name)): if not os.path.isdir(os.path.dirname(name)):
# The parent directory does not exist, create them # The parent directory does not exist, create them
if makedirs: 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']( __salt__['file.makedirs'](
name, user=user, group=group, mode=dir_mode name, user=user, group=group, mode=dir_mode
) )