Skip to content

Commit

Permalink
Removing unnecessary creation, logging, and checking for the existenc…
Browse files Browse the repository at this point in the history
…e of a bucket.
  • Loading branch information
Chrystinne committed Nov 15, 2023
1 parent 0f08483 commit fcf5f20
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions physionet-django/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,6 @@ def send_files_to_aws(pid):
up for the S3 client.
"""
project = PublishedProject.objects.get(id=pid)
# Create or get the associated AWS object
AWS.objects.get_or_create(project=project)
upload_project_to_S3(project)
project.aws.sent_files = True
project.aws.finished_datetime = timezone.now()
Expand Down Expand Up @@ -1103,10 +1101,9 @@ def aws_bucket_management(request, project, user):
"""
Manage AWS S3 bucket for a project.
This function is responsible for creating an AWS S3 bucket and
sending the project's files to that bucket. It orchestrates the
necessary steps to set up the bucket and populate it with the
project's data.
This function is responsible for sending the project's files
to that bucket. It orchestrates the necessary steps to set up
the bucket and populate it with the project's data.
Args:
project (PublishedProject): The project for which to create and
Expand All @@ -1126,16 +1123,10 @@ def aws_bucket_management(request, project, user):

bucket_name = get_bucket_name(project)

try:
AWS.objects.get(bucket_name=bucket_name)
messages.success(request, "The bucket already exists. Resending the \
files for the project {0}.".format(project))
except AWS.DoesNotExist:
if check_s3_bucket_exists(project):
LOGGER.info("The bucket {0} already exists, skipping bucket \
creation".format(bucket_name))
AWS.objects.create(project=project, bucket_name=bucket_name,
is_private=is_private)
if not AWS.objects.filter(project=project).exists():
AWS.objects.create(
project=project, bucket_name=bucket_name, is_private=is_private
)

send_files_to_aws(project.id, verbose_name='AWS - {}'.format(project), creator=user)

Expand Down

0 comments on commit fcf5f20

Please sign in to comment.