[PB-6023]: feat: implement bulk folder creation#965
Conversation
70aa9a1 to
cb561d9
Compare
| async createBulkFolders(user: User, dto: CreateFolderDto): Promise<Folder[]> { | ||
| const folders = dto.folders; | ||
|
|
||
| const parentFolder = await this.folderRepository.findOne({ |
There was a problem hiding this comment.
Should we filter by removed = false for consistency reasons?
| 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'); |
There was a problem hiding this comment.
Wasn't this a 409 conflict or am I remembering it wrong?
|
This PR is stale because it has been open for more than 15 days with no activity. |
| if (existingFolders.length > 0) { | ||
| const conflictingNames = existingFolders.map((f) => f.plainName); | ||
| throw new ConflictException( | ||
| `Folders already exist: ${conflictingNames.join(', ')}`, | ||
| ); | ||
| } |
There was a problem hiding this comment.
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
…tion for duplicate names and filter removed parent folders
…sponse for duplicate names
a4a34ad to
924ce73
Compare
|



POST /folders/bulkto create up to 15 folders under the same parent in a single request