Skip to content

Commit

Permalink
export avatars to own directory
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
hughrun committed Apr 13, 2024
1 parent 5d597f1 commit 501fb45
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions bookwyrm/models/bookwyrm_export_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ def create_archive_task(job_id):
images_storage = storage_backends.ImagesStorage()

if user.avatar:
add_file_to_s3_tar(
s3_tar, images_storage, user.avatar, directory="images"
)
add_file_to_s3_tar(s3_tar, images_storage, user.avatar)

for edition in editions:
if edition.cover:
Expand All @@ -166,7 +164,7 @@ def create_archive_task(job_id):

# Add avatar image if present
if user.avatar:
tar.add_image(user.avatar, directory="images")
tar.add_image(user.avatar)

for edition in editions:
if edition.cover:
Expand Down Expand Up @@ -196,7 +194,7 @@ def export_user(user: User):
"""export user data"""
data = user.to_activity()
if user.avatar:
data["icon"]["url"] = archive_file_location(user.avatar, directory="images")
data["icon"]["url"] = archive_file_location(user.avatar)
else:
data["icon"] = {}
return data
Expand Down

0 comments on commit 501fb45

Please sign in to comment.