Nested Folders: Decrease max nested folders depth (#78133)

* Nested Folders: Decrease allowed nested folders depth

* Fix folder height check in Move
This commit is contained in:
Tania 2023-11-15 01:25:40 -08:00 committed by GitHub
parent 20f541d7e7
commit 1d1d42c984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -698,8 +698,8 @@ func (s *Service) Move(ctx context.Context, cmd *folder.MoveFolderCommand) (*fol
return nil, err
}
// current folder height + current folder + parent folder + parent folder depth should be less than or equal 8
if folderHeight+len(parents)+2 > folder.MaxNestedFolderDepth {
// height of the folder that is being moved + this current folder itself + depth of the NewParent folder should be less than or equal MaxNestedFolderDepth
if folderHeight+len(parents)+1 > folder.MaxNestedFolderDepth {
return nil, folder.ErrMaximumDepthReached.Errorf("failed to move folder")
}
@ -961,7 +961,7 @@ func (s *Service) validateParent(ctx context.Context, orgID int64, parentUID str
return fmt.Errorf("failed to get parents: %w", err)
}
if len(ancestors) == folder.MaxNestedFolderDepth {
if len(ancestors) >= folder.MaxNestedFolderDepth {
return folder.ErrMaximumDepthReached.Errorf("failed to validate parent folder")
}

View File

@ -20,7 +20,7 @@ var ErrTargetRegistrySrvConflict = errutil.Internal("folder.target-registry-srv-
const (
GeneralFolderUID = "general"
RootFolderUID = ""
MaxNestedFolderDepth = 8
MaxNestedFolderDepth = 4
)
var ErrFolderNotFound = errutil.NotFound("folder.notFound")