Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure file system #167

Closed
yuanchen233 opened this issue Oct 30, 2024 · 3 comments · Fixed by #196
Closed

Restructure file system #167

yuanchen233 opened this issue Oct 30, 2024 · 3 comments · Fixed by #196
Assignees
Labels
enhancement New feature or request

Comments

@yuanchen233
Copy link
Collaborator

yuanchen233 commented Oct 30, 2024

Currently the file system accepting file upload and storage it under carp/storage, we should create a subfolder for each study and storage related resources under this study-subfolder. Once a study is deleted, the corresponding folder and resources should also be deleted.

and also for s3?

@bardram bardram added the enhancement New feature or request label Oct 31, 2024
@pavliuc75 pavliuc75 self-assigned this Nov 26, 2024
@bardram
Copy link
Collaborator

bardram commented Dec 11, 2024

Remember to check the download / export scripts when changing the file structure.

@pavliuc75 pavliuc75 changed the title Restructure file system Restructure file system (not export) Dec 16, 2024
@pavliuc75 pavliuc75 changed the title Restructure file system (not export) (!!! DONT MERGE BEFORE MIGRATION) Restructure file system (not export) Dec 16, 2024
@pavliuc75
Copy link
Contributor

What we change?
-how we save export (depl/study)
-change the controller
-change to db (ownerId, deploymentId, studyId)

Image

@pavliuc75 pavliuc75 changed the title (!!! DONT MERGE BEFORE MIGRATION) Restructure file system (not export) (!!! DONT MERGE BEFORE MIGRATION) Restructure file system Dec 19, 2024
@pavliuc75 pavliuc75 changed the title (!!! DONT MERGE BEFORE MIGRATION) Restructure file system Restructure file system Jan 16, 2025
@pavliuc75
Copy link
Contributor

pavliuc75 commented Jan 16, 2025

Database changes:

DELETE FROM public.files;
DELETE FROM public.exports;

ALTER TABLE public.files
ADD COLUMN owner_id VARCHAR(255),
ADD COLUMN deployment_id VARCHAR(255),
ADD COLUMN relative_path VARCHAR(1000),
RENAME COLUMN storage_name TO file_name;

ALTER TABLE public.exports
ADD COLUMN relative_path VARCHAR(1000);

File system new structure:
When uploading a file:
.../studies/1234/deployments/5678/{newFile.jpg}
When generating an export for a deployment:
.../studies/1234/deployments/5678/exports/{theExport.zip}
When generating an export for the entire study:
.../studies/1234/exports/{theExport.zip}

RestAPI changes in FileController:

  • the create ("/api/studies/{{STUDY_ID}}/files") is renamed to createDEPRECATED
  • a new endpoint is added -> create ("/api/studies/{{STUDY_ID}}/files/{{DEPLOYMENT_ID}}")

Caveats:
since some clients will still be using the createDEPRECATED endpoint, there is no way we can know the deploymentId when saving to database. If that's the case, the deploymentId for that row in db will be null, while the file will be saved with the relative path e.g. .../studies/1234/deployments/unknown/{newFile.jpg}. When generating an export for the entire study, we include the files from the unknown folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants