Refactor file organization#4278
Open
SteRiccio wants to merge 10 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors how survey/record file contents are organized in external storage (filesystem and S3) by moving from a flat naming scheme to a structured {surveyId}/{survey_files|record_files}/{fileUuid} layout, and adds a data migration step to move existing stored files into the new format.
Changes:
- Add startup data migration to move existing survey files to the new filesystem/S3 path/key format (gated by DB app version
< 2.5.6). - Update file storage repositories and survey file manager to read/write/delete file contents using the new path/key layout (distinguishing record vs survey files).
- Add migration helpers for filesystem renames and S3 copy+delete operations, plus a repository query to fetch file summaries by UUIDs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| server/utils/file/fileUtils.js | Adds an async rename helper used by filesystem migration. |
| server/system/dataMigrator/index.js | Adds version-gated migration hook to move stored files to the new path format. |
| server/modules/survey/service/surveyFileService.js | Adds service-level migration runner across all surveys. |
| server/modules/survey/manager/surveyFileManager.js | Propagates recordUuid into storage operations and adds per-survey migration logic. |
| server/modules/record/repository/fileRepositoryS3Bucket.js | Implements new S3 key layout and legacy→new key migration. |
| server/modules/record/repository/fileRepositoryFileSystem.js | Implements new filesystem layout and legacy→new path migration. |
| server/modules/record/repository/fileRepository.js | Adds fetchFileSummariesByUuids to support record-vs-survey file deletion routing. |
| server/modules/file/repository/fileRepositoryS3BucketCommon.js | Adds shared S3 helpers (head/copy/delete) used by key migration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No description provided.