From 4e70c9402ae70e777b0457823a0a92d8d598ef6a Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 25 May 2018 12:03:57 -0700 Subject: [PATCH] export: Fix path logic for exporting avatars with S3 backend. Apparently, we missed this when we converted the export format to use longer path names for avatars. --- zerver/lib/export.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zerver/lib/export.py b/zerver/lib/export.py index 4ceaf88286..b06563883c 100644 --- a/zerver/lib/export.py +++ b/zerver/lib/export.py @@ -916,17 +916,16 @@ def export_files_from_s3(realm: Realm, bucket_name: str, output_dir: Path, record['user_profile_email'] = user_profile.email if processing_avatars: - dirname = output_dir - filename = os.path.join(dirname, key.name) + filename = os.path.join(output_dir, key.name) record['path'] = key.name else: fields = key.name.split('/') if len(fields) != 3: raise AssertionError("Suspicious key with invalid format %s" % (key.name)) - dirname = os.path.join(output_dir, fields[1]) - filename = os.path.join(dirname, fields[2]) + filename = os.path.join(output_dir, fields[1], fields[2]) record['path'] = os.path.join(fields[1], fields[2]) + dirname = os.path.dirname(filename) if not os.path.exists(dirname): os.makedirs(dirname) key.get_contents_to_filename(filename)