fix avatar import path

This commit is contained in:
Hugh Rundle 2024-01-28 15:56:44 +11:00
parent 582e97e4a5
commit a3e05254b5
No known key found for this signature in database
GPG key ID: A7E35779918253F9
2 changed files with 38 additions and 38 deletions

View file

@ -246,9 +246,7 @@ class AddFileToTar(ChildJob):
# Add avatar image if present
if getattr(user, "avatar", False):
tar.add_image(
user.avatar, filename="avatar", directory="avatar/"
)
tar.add_image(user.avatar, filename="avatar")
for book in editions:
if getattr(book, "cover", False):
@ -284,7 +282,6 @@ def start_export_task(**kwargs):
job.user.save()
job.export_json = job.user.to_activity()
logger.info(job.export_json)
job.save(update_fields=["export_data", "export_json"])
# let's go
@ -345,16 +342,12 @@ def export_reading_goals_task(**kwargs):
def json_export(**kwargs):
"""Generate an export for a user"""
try:
job = BookwyrmExportJob.objects.get(id=kwargs["job_id"])
job.set_status("active")
job_id = kwargs["job_id"]
# I don't love this but it prevents a JSON encoding error
# when there is no user image
if isinstance(
job.export_json["icon"],
dataclasses._MISSING_TYPE, # pylint: disable=protected-access
):
if not job.export_json.get("icon"):
job.export_json["icon"] = {}
else:
# change the URL to be relative to the JSON file
@ -384,6 +377,13 @@ def json_export(**kwargs):
export_blocks_task.delay(job_id=job_id, no_children=False)
trigger_books_jobs.delay(job_id=job_id, no_children=False)
except Exception as err: # pylint: disable=broad-except
logger.exception(
"json_export task in job %s Failed with error: %s",
job.id,
err,
)
job.set_status("failed")
@app.task(queue=IMPORTS, base=ParentTask)
def trigger_books_jobs(**kwargs):

View file

@ -215,7 +215,7 @@ def upsert_statuses(user, cls, data, book_remote_id):
instance.save() # save and broadcast
else:
logger.info("User does not have permission to import statuses")
logger.warning("User does not have permission to import statuses")
def upsert_lists(user, lists, book_id):