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.
This commit is contained in:
Tim Abbott 2018-05-25 12:03:57 -07:00
parent 20aa3233b0
commit 4e70c9402a
1 changed files with 3 additions and 4 deletions

View File

@ -916,17 +916,16 @@ def export_files_from_s3(realm: Realm, bucket_name: str, output_dir: Path,
record['user_profile_email'] = user_profile.email record['user_profile_email'] = user_profile.email
if processing_avatars: if processing_avatars:
dirname = output_dir filename = os.path.join(output_dir, key.name)
filename = os.path.join(dirname, key.name)
record['path'] = key.name record['path'] = key.name
else: else:
fields = key.name.split('/') fields = key.name.split('/')
if len(fields) != 3: if len(fields) != 3:
raise AssertionError("Suspicious key with invalid format %s" % (key.name)) raise AssertionError("Suspicious key with invalid format %s" % (key.name))
dirname = os.path.join(output_dir, fields[1]) filename = os.path.join(output_dir, fields[1], fields[2])
filename = os.path.join(dirname, fields[2])
record['path'] = os.path.join(fields[1], fields[2]) record['path'] = os.path.join(fields[1], fields[2])
dirname = os.path.dirname(filename)
if not os.path.exists(dirname): if not os.path.exists(dirname):
os.makedirs(dirname) os.makedirs(dirname)
key.get_contents_to_filename(filename) key.get_contents_to_filename(filename)