Fix T50244: bam pack with -m FILE fails on copying deeper hierachies because of missing destination folders.

As suggested by reporter, check for existing dst dir and use os.makedirs
first if missing.
This commit is contained in:
2016-12-14 14:16:04 +01:00
parent ac0c83d49d
commit b75b744032

View File

@@ -513,6 +513,9 @@ def pack(
if (not os.path.exists(src)) or os.path.isdir(src): if (not os.path.exists(src)) or os.path.isdir(src):
yield report(" %s: %r\n" % (colorize("source missing", color='red'), src)) yield report(" %s: %r\n" % (colorize("source missing", color='red'), src))
else: else:
dst_dir = os.path.dirname(dst)
if not os.path.exists(dst_dir):
os.makedirs(dst_dir)
yield report(" %s: %r -> %r\n" % (colorize("copying", color='blue'), src, dst)) yield report(" %s: %r -> %r\n" % (colorize("copying", color='blue'), src, dst))
shutil.copy(src, dst) shutil.copy(src, dst)