mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
fix avatar import path
This commit is contained in:
parent
582e97e4a5
commit
a3e05254b5
2 changed files with 38 additions and 38 deletions
|
@ -246,9 +246,7 @@ class AddFileToTar(ChildJob):
|
||||||
|
|
||||||
# Add avatar image if present
|
# Add avatar image if present
|
||||||
if getattr(user, "avatar", False):
|
if getattr(user, "avatar", False):
|
||||||
tar.add_image(
|
tar.add_image(user.avatar, filename="avatar")
|
||||||
user.avatar, filename="avatar", directory="avatar/"
|
|
||||||
)
|
|
||||||
|
|
||||||
for book in editions:
|
for book in editions:
|
||||||
if getattr(book, "cover", False):
|
if getattr(book, "cover", False):
|
||||||
|
@ -284,7 +282,6 @@ def start_export_task(**kwargs):
|
||||||
job.user.save()
|
job.user.save()
|
||||||
|
|
||||||
job.export_json = job.user.to_activity()
|
job.export_json = job.user.to_activity()
|
||||||
logger.info(job.export_json)
|
|
||||||
job.save(update_fields=["export_data", "export_json"])
|
job.save(update_fields=["export_data", "export_json"])
|
||||||
|
|
||||||
# let's go
|
# let's go
|
||||||
|
@ -345,16 +342,12 @@ def export_reading_goals_task(**kwargs):
|
||||||
def json_export(**kwargs):
|
def json_export(**kwargs):
|
||||||
"""Generate an export for a user"""
|
"""Generate an export for a user"""
|
||||||
|
|
||||||
|
try:
|
||||||
job = BookwyrmExportJob.objects.get(id=kwargs["job_id"])
|
job = BookwyrmExportJob.objects.get(id=kwargs["job_id"])
|
||||||
job.set_status("active")
|
job.set_status("active")
|
||||||
job_id = kwargs["job_id"]
|
job_id = kwargs["job_id"]
|
||||||
|
|
||||||
# I don't love this but it prevents a JSON encoding error
|
if not job.export_json.get("icon"):
|
||||||
# when there is no user image
|
|
||||||
if isinstance(
|
|
||||||
job.export_json["icon"],
|
|
||||||
dataclasses._MISSING_TYPE, # pylint: disable=protected-access
|
|
||||||
):
|
|
||||||
job.export_json["icon"] = {}
|
job.export_json["icon"] = {}
|
||||||
else:
|
else:
|
||||||
# change the URL to be relative to the JSON file
|
# 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)
|
export_blocks_task.delay(job_id=job_id, no_children=False)
|
||||||
trigger_books_jobs.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)
|
@app.task(queue=IMPORTS, base=ParentTask)
|
||||||
def trigger_books_jobs(**kwargs):
|
def trigger_books_jobs(**kwargs):
|
||||||
|
|
|
@ -215,7 +215,7 @@ def upsert_statuses(user, cls, data, book_remote_id):
|
||||||
instance.save() # save and broadcast
|
instance.save() # save and broadcast
|
||||||
|
|
||||||
else:
|
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):
|
def upsert_lists(user, lists, book_id):
|
||||||
|
|
Loading…
Reference in a new issue