From b75b74403251ea81ad11a11a4584a194688924ab Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 14 Dec 2016 14:16:04 +0100 Subject: [PATCH] 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. --- bam/blend/blendfile_pack.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bam/blend/blendfile_pack.py b/bam/blend/blendfile_pack.py index 16fa7ed..c91b242 100755 --- a/bam/blend/blendfile_pack.py +++ b/bam/blend/blendfile_pack.py @@ -513,6 +513,9 @@ def pack( if (not os.path.exists(src)) or os.path.isdir(src): yield report(" %s: %r\n" % (colorize("source missing", color='red'), src)) 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)) shutil.copy(src, dst)