mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
complete jobs more sensibly
- fix tuple in tar export I accidentally broke by following pylint blindly - just use job.set_status to complete jobs since it does everything we need - fix/avoid Celery "not JSON deserializable" error by not saving whole job including user value
This commit is contained in:
parent
ddec2dbaa9
commit
e29c93a1e9
2 changed files with 5 additions and 7 deletions
|
@ -42,13 +42,12 @@ def start_export_task(**kwargs):
|
|||
job.export_data = ContentFile(b"", str(uuid4()))
|
||||
json_data = json_export(job.user)
|
||||
tar_export(json_data, job.user, job.export_data)
|
||||
job.save(update_fields=["export_data"])
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
logger.exception("User Export Job %s Failed with error: %s", job.id, err)
|
||||
job.set_status("failed")
|
||||
job.set_status(
|
||||
"complete"
|
||||
) # need to explicitly set this here to trigger notifications
|
||||
job.save(update_fields=["export_data"])
|
||||
|
||||
job.set_status("complete")
|
||||
|
||||
|
||||
def tar_export(json_data: str, user, file):
|
||||
|
@ -61,7 +60,7 @@ def tar_export(json_data: str, user, file):
|
|||
if getattr(user, "avatar", False):
|
||||
tar.add_image(user.avatar, filename="avatar")
|
||||
|
||||
editions = get_books_for_user(user)
|
||||
editions, books = get_books_for_user(user) # pylint: disable=unused-argument
|
||||
for book in editions:
|
||||
if getattr(book, "cover", False):
|
||||
tar.add_image(book.cover)
|
||||
|
|
|
@ -61,8 +61,7 @@ def start_import_task(**kwargs):
|
|||
|
||||
process_books(job, tar)
|
||||
|
||||
job.set_status("complete") # set here to trigger notifications
|
||||
job.save()
|
||||
job.set_status("complete")
|
||||
archive_file.close()
|
||||
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
|
|
Loading…
Reference in a new issue