Better errors for mkdirp failure in mirror.

This commit is contained in:
Todd Gamblin 2016-01-24 16:16:43 -08:00
parent 64a9549225
commit be354e85c9

View File

@ -147,7 +147,11 @@ def create(path, specs, **kwargs):
# Get the absolute path of the root before we start jumping around.
mirror_root = os.path.abspath(path)
if not os.path.isdir(mirror_root):
try:
mkdirp(mirror_root)
except OSError as e:
raise MirrorError(
"Cannot create directory '%s':" % mirror_root, str(e))
# Things to keep track of while parsing specs.
present = []
@ -164,7 +168,11 @@ def create(path, specs, **kwargs):
# create a subdirectory for the current package@version
archive_path = os.path.abspath(join_path(mirror_root, mirror_archive_path(spec)))
subdir = os.path.dirname(archive_path)
try:
mkdirp(subdir)
except OSError as e:
raise MirrorError(
"Cannot create directory '%s':" % subdir, str(e))
if os.path.exists(archive_path):
tty.msg("Already added %s" % spec.format("$_$@"))