[nested folder]Add circular reference detection in create nested folder (#60163)
* add circulic reference detection in create neste folder * redeclare mock * add log for getHeight when depassing limit
This commit is contained in:
@@ -268,7 +268,7 @@ func (ss *sqlStore) getParentsMySQL(ctx context.Context, cmd folder.GetParentsQu
|
||||
func (ss *sqlStore) GetHeight(ctx context.Context, foldrUID string, orgID int64, parentUID *string) (int, error) {
|
||||
height := -1
|
||||
queue := []string{foldrUID}
|
||||
for len(queue) > 0 {
|
||||
for len(queue) > 0 && height <= folder.MaxNestedFolderDepth {
|
||||
length := len(queue)
|
||||
height++
|
||||
for i := 0; i < length; i++ {
|
||||
@@ -286,5 +286,8 @@ func (ss *sqlStore) GetHeight(ctx context.Context, foldrUID string, orgID int64,
|
||||
}
|
||||
}
|
||||
}
|
||||
if height > folder.MaxNestedFolderDepth {
|
||||
ss.log.Warn("folder height exceeds the maximum allowed depth, You might have a circular reference", "uid", foldrUID, "orgId", orgID, "maxDepth", folder.MaxNestedFolderDepth)
|
||||
}
|
||||
return height, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user