diff --git a/cmd/version.go b/cmd/version.go index a77b0b7..7c220af 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -var Version = "0.36.0" +var Version = "0.36.1" func init() { rootCmd.AddCommand(versionCmd) diff --git a/cmd/web.go b/cmd/web.go index 7926af9..e6bfbbd 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -183,20 +183,26 @@ func (s *ServeStats) incrementCounter(image string, timestamp time.Time, filesiz func (s *ServeStats) ListImages() ([]byte, error) { s.mutex.RLock() - sortedList := s.list + sortedList := &ServeStats{ + mutex: sync.RWMutex{}, + list: s.list, + count: s.count, + size: s.size, + times: s.times, + } - sort.SliceStable(sortedList, func(p, q int) bool { - return sortedList[p] < sortedList[q] + s.mutex.RUnlock() + + sort.SliceStable(sortedList.list, func(p, q int) bool { + return sortedList.list[p] < sortedList.list[q] }) a := []timesServed{} - for _, image := range s.list { - a = append(a, timesServed{image, s.count[image], s.size[image], s.times[image]}) + for _, image := range sortedList.list { + a = append(a, timesServed{image, sortedList.count[image], sortedList.size[image], sortedList.times[image]}) } - s.mutex.RUnlock() - r, err := json.MarshalIndent(a, "", " ") if err != nil { return []byte{}, err