From 01629da4071f751b9c4fdc7d14f7ff43d2aa563b Mon Sep 17 00:00:00 2001 From: Seednode Date: Sun, 13 Aug 2023 17:29:28 -0500 Subject: [PATCH] Replaced uint64 with uint32 --- cmd/files.go | 30 +++++++++++++++--------------- cmd/root.go | 2 +- cmd/web.go | 12 ++++++------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/cmd/files.go b/cmd/files.go index eefbb72..885cc0f 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -63,10 +63,10 @@ func (f *Files) Append(directory, path string) { } type ScanStats struct { - filesMatched atomic.Uint64 - filesSkipped atomic.Uint64 - directoriesMatched atomic.Uint64 - directoriesSkipped atomic.Uint64 + filesMatched atomic.Uint32 + filesSkipped atomic.Uint32 + directoriesMatched atomic.Uint32 + directoriesSkipped atomic.Uint32 } type Path struct { @@ -155,7 +155,7 @@ func appendPath(directory, path string, files *Files, stats *ScanStats, shouldCa files.Append(directory, path) - stats.filesMatched.Add(uint64(1)) + stats.filesMatched.Add(1) return nil } @@ -415,9 +415,9 @@ func pathHasSupportedFiles(path string) (bool, error) { } } -func pathCount(path string) (int, int, error) { - directories := 0 - files := 0 +func pathCount(path string) (uint32, uint32, error) { + var directories uint32 = 0 + var files uint32 = 0 nodes, err := os.ReadDir(path) if err != nil { @@ -473,10 +473,10 @@ func scanPath(path string, files *Files, filters *Filters, stats *ScanStats, con fmt.Println(err) } - if files > 0 && (files < int(minimumFileCount) || files > int(maximumFileCount)) { + if files > 0 && (files < minimumFileCount) || (files > maximumFileCount) { // This count will not otherwise include the parent directory itself, so increment by one - stats.directoriesSkipped.Add(uint64(directories + 1)) - stats.filesSkipped.Add(uint64(files)) + stats.directoriesSkipped.Add(directories + 1) + stats.filesSkipped.Add(files) return filepath.SkipDir } @@ -509,10 +509,10 @@ func fileList(paths []string, filters *Filters, sort string, index *Index) ([]st } stats := &ScanStats{ - filesMatched: atomic.Uint64{}, - filesSkipped: atomic.Uint64{}, - directoriesMatched: atomic.Uint64{}, - directoriesSkipped: atomic.Uint64{}, + filesMatched: atomic.Uint32{}, + filesSkipped: atomic.Uint32{}, + directoriesMatched: atomic.Uint32{}, + directoriesSkipped: atomic.Uint32{}, } concurrency := &Concurrency{ diff --git a/cmd/root.go b/cmd/root.go index 8b3c1e9..af1388e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,7 @@ import ( ) const ( - Version string = "0.56.0" + Version string = "0.56.1" ) var ( diff --git a/cmd/web.go b/cmd/web.go index 3867fe2..08182a8 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -171,14 +171,14 @@ func (i *Index) Import(path string) error { type ServeStats struct { mutex sync.RWMutex list []string - count map[string]uint64 + count map[string]uint32 size map[string]string times map[string][]string } type exportedServeStats struct { List []string - Count map[string]uint64 + Count map[string]uint32 Size map[string]string Times map[string][]string } @@ -205,7 +205,7 @@ func (s *ServeStats) incrementCounter(image string, timestamp time.Time, filesiz func (s *ServeStats) toExported() *exportedServeStats { stats := &exportedServeStats{ List: make([]string, len(s.list)), - Count: make(map[string]uint64), + Count: make(map[string]uint32), Size: make(map[string]string), Times: make(map[string][]string), } @@ -316,7 +316,7 @@ func (s *ServeStats) Import(path string) error { stats := &exportedServeStats{ List: []string{}, - Count: make(map[string]uint64), + Count: make(map[string]uint32), Size: make(map[string]string), Times: make(map[string][]string), } @@ -333,7 +333,7 @@ func (s *ServeStats) Import(path string) error { type timesServed struct { File string - Served uint64 + Served uint32 Size string Times []string } @@ -1013,7 +1013,7 @@ func ServePage(args []string) error { stats := &ServeStats{ mutex: sync.RWMutex{}, list: []string{}, - count: make(map[string]uint64), + count: make(map[string]uint32), size: make(map[string]string), times: make(map[string][]string), }