export avatars to own directory

Saving avatars to /images is problematic because it changes the original filepath from avatars/filename to images/avatars/filename.
In this PR prior to this commit, imports failed as they are looking for a file path beginning with "avatar"
This commit is contained in:
Hugh Rundle 2024-04-13 12:03:35 +10:00
parent 5d597f1ca9
commit 501fb45528
No known key found for this signature in database
GPG key ID: A7E35779918253F9

View file

@ -139,9 +139,7 @@ def create_archive_task(job_id):
images_storage = storage_backends.ImagesStorage() images_storage = storage_backends.ImagesStorage()
if user.avatar: if user.avatar:
add_file_to_s3_tar( add_file_to_s3_tar(s3_tar, images_storage, user.avatar)
s3_tar, images_storage, user.avatar, directory="images"
)
for edition in editions: for edition in editions:
if edition.cover: if edition.cover:
@ -166,7 +164,7 @@ def create_archive_task(job_id):
# Add avatar image if present # Add avatar image if present
if user.avatar: if user.avatar:
tar.add_image(user.avatar, directory="images") tar.add_image(user.avatar)
for edition in editions: for edition in editions:
if edition.cover: if edition.cover:
@ -196,7 +194,7 @@ def export_user(user: User):
"""export user data""" """export user data"""
data = user.to_activity() data = user.to_activity()
if user.avatar: if user.avatar:
data["icon"]["url"] = archive_file_location(user.avatar, directory="images") data["icon"]["url"] = archive_file_location(user.avatar)
else: else:
data["icon"] = {} data["icon"] = {}
return data return data