From fac5639ab79f2d2dba9537dcff4ffd491351e28a Mon Sep 17 00:00:00 2001 From: Connor van Spronssen Date: Mon, 27 Jan 2025 08:16:27 +0100 Subject: [PATCH] fix: Make the maxDepth variable global to the package --- cmd/cs_sdk/functions/sync.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/cs_sdk/functions/sync.go b/cmd/cs_sdk/functions/sync.go index 292db31..4269846 100644 --- a/cmd/cs_sdk/functions/sync.go +++ b/cmd/cs_sdk/functions/sync.go @@ -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) @@ -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") @@ -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") } @@ -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 {