fix: returns error on duplicate folder creation

This commit is contained in:
Piyush Gupta
2025-10-17 22:02:09 +05:30
parent bd18a61f35
commit 3ad79bc7ea
5 changed files with 97 additions and 30 deletions
@@ -118,24 +118,11 @@ export const secretFolderServiceFactory = ({
});
}
// check if the exact folder already exists
const existingFolder = await folderDAL.findOne(
{
envId: env.id,
parentId: parentFolder.id,
name,
isReserved: false
},
tx
);
if (existingFolder) {
return existingFolder;
}
// exact folder case
if (parentFolder.path === pathWithFolder) {
return parentFolder;
throw new BadRequestError({
message: `Folder with name '${name}' already exists in path '${secretPath}'`
});
}
let currentParentId = parentFolder.id;