Skip to content

Commit

Permalink
Fix double exports subdir in S3 user export
Browse files Browse the repository at this point in the history
  • Loading branch information
Minnozz committed Mar 27, 2024
1 parent c6ca547 commit cdbc1d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bookwyrm/models/bookwyrm_export_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def create_archive_task(job_id):

try:
export_task_id = job.task_id
archive_filename = f"{export_task_id}.tar.gz"
export_json_bytes = DjangoJSONEncoder().encode(job.export_json).encode("utf-8")

user = job.user
Expand All @@ -109,10 +110,9 @@ def create_archive_task(job_id):
storage = S3Boto3Storage()

# Handle for creating the final archive
s3_archive_path = f"exports/{export_task_id}.tar.gz"
s3_tar = S3Tar(
settings.AWS_STORAGE_BUCKET_NAME,
s3_archive_path,
f"exports/{archive_filename}",
session=BookwyrmAwsSession(),
)

Expand All @@ -135,14 +135,14 @@ def create_archive_task(job_id):

# Create archive and store file name
s3_tar.tar()
job.export_data = s3_archive_path
job.export_data = archive_filename
job.save(update_fields=["export_data"])

# Delete temporary files
S3Boto3Storage.delete(storage, export_json_tmp_file)

else:
job.export_data = f"{export_task_id}.tar.gz"
job.export_data = archive_filename
with job.export_data.open("wb") as tar_file:
with BookwyrmTarFile.open(mode="w:gz", fileobj=tar_file) as tar:
# save json file
Expand Down

0 comments on commit cdbc1d1

Please sign in to comment.