From cba38255a575ddbb32e0134242105a0898102bd5 Mon Sep 17 00:00:00 2001 From: Arnas Udovic Date: Sun, 6 Apr 2025 09:30:35 +0300 Subject: [PATCH] skip Files without Id; sort Files by Id --- tree.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tree.go b/tree.go index 70e6c50..78c8356 100644 --- a/tree.go +++ b/tree.go @@ -3,6 +3,7 @@ package zord_tree import ( "bufio" "bytes" + "cmp" "crypto/md5" "errors" "fmt" @@ -13,10 +14,10 @@ import ( "path" "path/filepath" "regexp" + "slices" "strings" abcex "g.arns.lt/zordsdavini/abcex/v4" - "golang.org/x/exp/slices" ) type Config struct { @@ -568,7 +569,16 @@ FILE_LOOP: if err != nil { return tree, err } + if nextFile.Id == "" { + continue + } tree.Files = append(tree.Files, nextFile) + slices.SortFunc(tree.Files, func(a, b File) int { + if len(a.Id) == len(b.Id) { + return strings.Compare(a.Id, b.Id) + } + return cmp.Compare(len(a.Id), len(b.Id)) + }) } return tree, nil