From b3d0fcb2435b8b44a7a17efdcebdddb0685b457f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 21 Apr 2017 16:24:20 +0200 Subject: [PATCH] Always try to pack using a unique temporary folder name. This allows multiple users to create multiple ZIP files in the same directory. --- bam/blend/blendfile_pack.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bam/blend/blendfile_pack.py b/bam/blend/blendfile_pack.py index 1600a22..8635618 100755 --- a/bam/blend/blendfile_pack.py +++ b/bam/blend/blendfile_pack.py @@ -219,10 +219,18 @@ def pack( # _dbg(blendfile_dst) if base_dir_dst_temp is None: - if mode == 'ZIP': - base_dir_dst_temp = os.path.join(base_dir_dst, b'__blendfile_temp__') - else: - base_dir_dst_temp = os.path.join(base_dir_dst, b'__blendfile_pack__') + # Always try to pack using a unique folder name. + import uuid + + suf = 'temp' if mode == 'ZIP' else 'pack' + + while True: + unique = uuid.uuid4().hex + name = '__blendfile_%s_%s__' % (unique, suf) + base_dir_dst_temp = os.path.join(base_dir_dst, name.encode('ascii')) + + if not os.path.exists(base_dir_dst_temp): + break def temp_remap_cb(filepath, rootdir): """