Skip to content

Refactor file organization#4278

Open
SteRiccio wants to merge 10 commits into
masterfrom
refactor/file-organization
Open

Refactor file organization#4278
SteRiccio wants to merge 10 commits into
masterfrom
refactor/file-organization

Conversation

@SteRiccio

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread server/modules/survey/manager/surveyFileManager.js Outdated
Comment thread server/modules/survey/manager/surveyFileManager.js Outdated
Comment thread server/modules/survey/service/surveyFileService.js Outdated
@mergify

mergify Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants