Skip to content

Commit

Permalink
fix: set correct permissions for uploaded file
Browse files Browse the repository at this point in the history
Fixes issue #1215
Looks like wasn't about http vs https, nginx was handling this
correctly, just different set of permissions for different targets,
probably an artefact of the way they were processed.
  • Loading branch information
kaliif committed Nov 17, 2023
1 parent 41d575f commit aad2475
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 1 addition & 5 deletions media_serve/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
from . import views

urlpatterns = [
# path("pdbs/<file_path>/", views.prot_download, name="get_protein"),
# path("pdbs/", views.prot_download, name="get_protein"),
# re_path(r"^pdbs/(?P<file_path>.+)", views.prot_download, name="get_protein"),
re_path(r"^pdbs/(?P<file_path>.+)", views.prot_download, name="get_protein"),
path("bound/<file_path>/", views.bound_download, name="get_bound"),
path("metadata/<file_path>/", views.metadata_download, name="get_metadata"),
path("targets/<file_path>/", views.archive_download, name="get_archive"),
path("maps/<file_path>/", views.map_download, name='get_map'),
# path("target_loader_data/<file_path>", views.file_download, name='get_file'),
# re_path(r"^target_loader_data/48225dbf-204a-48e1-8ae7-f1632f4dba89/Mpro-v2/Mpro/upload_2/aligned_files/Mpro_Nterm-x0029/(?P<file_path>.+)", views.file_download, name='get_file'),
re_path(r"^target_loader_data/(?P<file_path>.+)", views.tld_download, name="get_tld"),
re_path(r"^pdbs/(?P<file_path>.+)", views.file_download, name="get_file"),
]
16 changes: 16 additions & 0 deletions viewer/target_loader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from dataclasses import dataclass
from typing import Any
import logging
Expand Down Expand Up @@ -1336,6 +1337,8 @@ def load_target(
target_loader.abs_final_path.parent.joinpath(target_loader.data_bundle)
)

set_directory_permissions(target_loader.abs_final_path, 0o755)

update_task(task, "SUCCESS", upload_report)
target_loader.experiment_upload.message = upload_report

Expand All @@ -1355,3 +1358,16 @@ def update_task(task, state, message):
except AttributeError:
# no task passed to method, nothing to do
pass


def set_directory_permissions(path, permissions):
for root, dirs, files in os.walk(path):
# Set permissions for directories
for directory in dirs:
dir_path = os.path.join(root, directory)
os.chmod(dir_path, permissions)

# Set permissions for files
for file in files:
file_path = os.path.join(root, file)
os.chmod(file_path, permissions)

0 comments on commit aad2475

Please sign in to comment.