Skip to content

[PB-6023]: feat: implement bulk folder creation#965

Merged
jzunigax2 merged 4 commits intomasterfrom
feat/bulk-create-folders
Apr 13, 2026
Merged

[PB-6023]: feat: implement bulk folder creation#965
jzunigax2 merged 4 commits intomasterfrom
feat/bulk-create-folders

Conversation

@jzunigax2
Copy link
Copy Markdown
Contributor

@jzunigax2 jzunigax2 commented Mar 3, 2026

  • Adds POST /folders/bulk to create up to 15 folders under the same parent in a single request
  • All-or-nothing: validates all names upfront, inserts in a single DB query if any fails, none are created

@jzunigax2 jzunigax2 force-pushed the feat/bulk-create-folders branch from 70aa9a1 to cb561d9 Compare March 4, 2026 14:29
@jzunigax2 jzunigax2 self-assigned this Mar 4, 2026
@jzunigax2 jzunigax2 marked this pull request as ready for review March 4, 2026 15:19
@jzunigax2 jzunigax2 requested a review from apsantiso as a code owner March 4, 2026 15:19
@jzunigax2 jzunigax2 requested a review from sg-gs March 4, 2026 15:21
Comment thread src/modules/folder/folder.controller.ts Outdated
async createBulkFolders(user: User, dto: CreateFolderDto): Promise<Folder[]> {
const folders = dto.folders;

const parentFolder = await this.folderRepository.findOne({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we filter by removed = false for consistency reasons?

Comment thread src/modules/folder/folder.usecase.ts Outdated
const plainNames = folders.map((f) => f.plainName);
const uniqueNames = new Set(plainNames);
if (uniqueNames.size !== plainNames.length) {
throw new BadRequestException('Duplicate folder names in request');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wasn't this a 409 conflict or am I remembering it wrong?

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for more than 15 days with no activity.

Comment on lines +506 to +511
if (existingFolders.length > 0) {
const conflictingNames = existingFolders.map((f) => f.plainName);
throw new ConflictException(
`Folders already exist: ${conflictingNames.join(', ')}`,
);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Send this in an object if possible. We do not want the clients to try to parse the string in order to know which folders are already existent.

If you set an object in the conflictException it is able to parse it without any issue try to accomplish something like:

{
    "message": "File already exists",
    "error": "Conflict",
    "statusCode": 409,
    "existentFolders": [...]
}

Not sure if there is another good format for this tho, up to you @jzunigax2

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 6, 2026

@jzunigax2 jzunigax2 requested a review from apsantiso April 7, 2026 21:38
@jzunigax2 jzunigax2 merged commit 2c178a3 into master Apr 13, 2026
13 checks passed
@jzunigax2 jzunigax2 deleted the feat/bulk-create-folders branch April 13, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants