Skip to content

Commit

Permalink
fix: Make the maxDepth variable global to the package
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobefu committed Jan 27, 2025
1 parent 0a50d9b commit fac5639
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cmd/cs_sdk/functions/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
db_structs "github.com/Dobefu/csb/cmd/database/structs"
)

const maxDepth uint8 = 10

func Sync(reset bool) error {
routes := make(map[string]structs.Route)

Expand Down Expand Up @@ -346,7 +348,6 @@ func addParentRoutes(routes *map[string]structs.Route) error {
}

func addRouteChildren(route structs.Route, routes *map[string]structs.Route, depth uint8) error {
const maxDepth uint8 = 10

if depth > maxDepth {
return errors.New("potential infinite loop detected")
Expand Down Expand Up @@ -378,8 +379,6 @@ func addRouteChildren(route structs.Route, routes *map[string]structs.Route, dep
}

func addRouteParents(route structs.Route, routes *map[string]structs.Route, depth uint8) error {
const maxDepth uint8 = 10

if depth > maxDepth {
return errors.New("potential infinite loop detected")
}
Expand Down Expand Up @@ -610,7 +609,6 @@ func constructRouteUrl(route structs.Route, routes map[string]structs.Route) str
currentRoute := route

var depth uint8 = 0
const maxDepth uint8 = 10

for {
if depth > maxDepth {
Expand Down

0 comments on commit fac5639

Please sign in to comment.