Skip to content

Commit

Permalink
Removing version information from open bucket prefixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrystinne committed Oct 16, 2023
1 parent f0f1989 commit 1cf59e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
16 changes: 7 additions & 9 deletions physionet-django/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,12 +796,14 @@ 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_instance = AWS.objects.get_or_create(project=project)
upload_project_to_S3(project)
project.aws.sent_files = True
project.aws.finished_datetime = timezone.now()
aws_instance.sent_files = True
aws_instance.finished_datetime = timezone.now()
if project.compressed_storage_size:
project.aws.sent_zip = True
project.aws.save()
aws_instance.sent_zip = True
aws_instance.save()


@associated_task(PublishedProject, "pid", read_only=True)
Expand Down Expand Up @@ -1133,17 +1135,13 @@ def aws_bucket_management(request, project, user):
bucket_name = get_bucket_name(project)

try:
aws_object = AWS.objects.get(bucket_name=bucket_name)
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))
# else:
# create_bucket(project.slug, project.version, project.title, is_private)
# messages.success(request, "The GCP bucket for project {0} was \
# successfully created.".format(project))
AWS.objects.create(project=project, bucket_name=bucket_name,
is_private=is_private)

Expand Down
3 changes: 1 addition & 2 deletions physionet-django/project/cloud/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,13 +712,12 @@ def upload_project_to_S3(project):

# upload files to bucket
folder_path = project.project_file_root()
project_name = project.slug + "-" + project.version

# set the prefix only for the projects
# in the open data bucket
s3_prefix = ""
if project.access_policy == AccessPolicy.OPEN:
s3_prefix = f"{project_name}/"
s3_prefix = f"{project.slug}/"
send_files_to_s3(folder_path, s3_prefix, bucket_name)


Expand Down
2 changes: 1 addition & 1 deletion physionet-django/project/migrations/0071_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Migration(migrations.Migration):
"project",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
related_name='aws',
related_name='aws',
to='project.PublishedProject'
),
),
Expand Down

0 comments on commit 1cf59e2

Please sign in to comment.