mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-12 18:25:35 +00:00
subclass boto3 session instead of adding new env value
Thanks Dato!
This commit is contained in:
parent
f96ddaa3e1
commit
5f7be848fc
2 changed files with 3 additions and 7 deletions
|
@ -81,7 +81,6 @@ AWS_SECRET_ACCESS_KEY=
|
||||||
# AWS_S3_CUSTOM_DOMAIN=None # "example-bucket-name.s3.fr-par.scw.cloud"
|
# AWS_S3_CUSTOM_DOMAIN=None # "example-bucket-name.s3.fr-par.scw.cloud"
|
||||||
# AWS_S3_REGION_NAME=None # "fr-par"
|
# AWS_S3_REGION_NAME=None # "fr-par"
|
||||||
# AWS_S3_ENDPOINT_URL=None # "https://s3.fr-par.scw.cloud"
|
# AWS_S3_ENDPOINT_URL=None # "https://s3.fr-par.scw.cloud"
|
||||||
# S3_ENDPOINT_URL=None # same as AWS_S3_ENDPOINT_URL - needed for non-AWS for user exports
|
|
||||||
|
|
||||||
# Commented are example values if you use Azure Blob Storage
|
# Commented are example values if you use Azure Blob Storage
|
||||||
# USE_AZURE=true
|
# USE_AZURE=true
|
||||||
|
|
|
@ -29,9 +29,9 @@ logger = logging.getLogger(__name__)
|
||||||
class BookwyrmAwsSession(BotoSession):
|
class BookwyrmAwsSession(BotoSession):
|
||||||
"""a boto session that always uses settings.AWS_S3_ENDPOINT_URL"""
|
"""a boto session that always uses settings.AWS_S3_ENDPOINT_URL"""
|
||||||
|
|
||||||
def client(service_name, **kwargs):
|
def client(self, *args, **kwargs): # pylint: disable=arguments-differ
|
||||||
kwargs["endpoint_url"] = settings.AWS_S3_ENDPOINT_URL
|
kwargs["endpoint_url"] = settings.AWS_S3_ENDPOINT_URL
|
||||||
return super().client(service_name, **kwargs)
|
return super().client("s3", *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class BookwyrmExportJob(ParentJob):
|
class BookwyrmExportJob(ParentJob):
|
||||||
|
@ -42,9 +42,7 @@ class BookwyrmExportJob(ParentJob):
|
||||||
else:
|
else:
|
||||||
storage = storage_backends.ExportsFileStorage
|
storage = storage_backends.ExportsFileStorage
|
||||||
|
|
||||||
export_data = FileField(
|
export_data = FileField(null=True, storage=storage)
|
||||||
null=True, storage=storage
|
|
||||||
) # use custom storage backend here
|
|
||||||
export_json = JSONField(null=True, encoder=DjangoJSONEncoder)
|
export_json = JSONField(null=True, encoder=DjangoJSONEncoder)
|
||||||
json_completed = BooleanField(default=False)
|
json_completed = BooleanField(default=False)
|
||||||
|
|
||||||
|
@ -70,7 +68,6 @@ class BookwyrmExportJob(ParentJob):
|
||||||
self.json_completed = True
|
self.json_completed = True
|
||||||
self.save(update_fields=["json_completed"])
|
self.save(update_fields=["json_completed"])
|
||||||
|
|
||||||
# add json file to tarfile
|
|
||||||
tar_job = AddFileToTar.objects.create(
|
tar_job = AddFileToTar.objects.create(
|
||||||
parent_job=self, parent_export_job=self
|
parent_job=self, parent_export_job=self
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue