Revert "Revert "Merge branch 'master' of https://github.com/seaweedfs/seaweedfs""

This reverts commit 8cb42c39
This commit is contained in:
chrislu
2023-09-25 09:35:16 -07:00
parent 3d07895518
commit 645ae8c57b
23 changed files with 84 additions and 70 deletions

View File

@@ -7,6 +7,7 @@ import (
"path"
"regexp"
"strconv"
"strings"
"github.com/seaweedfs/seaweedfs/weed/storage/erasure_coding"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
@@ -144,8 +145,8 @@ func (l *DiskLocation) loadAllEcShards() (err error) {
}
dirEntries = append(dirEntries, indexDirEntries...)
}
slices.SortFunc(dirEntries, func(a, b os.DirEntry) bool {
return a.Name() < b.Name()
slices.SortFunc(dirEntries, func(a, b os.DirEntry) int {
return strings.Compare(a.Name(), b.Name())
})
var sameVolumeShards []string
var prevVolumeId needle.VolumeId

View File

@@ -84,8 +84,11 @@ func (ev *EcVolume) AddEcVolumeShard(ecVolumeShard *EcVolumeShard) bool {
}
}
ev.Shards = append(ev.Shards, ecVolumeShard)
slices.SortFunc(ev.Shards, func(a, b *EcVolumeShard) bool {
return a.VolumeId < b.VolumeId || a.VolumeId == b.VolumeId && a.ShardId < b.ShardId
slices.SortFunc(ev.Shards, func(a, b *EcVolumeShard) int {
if a.VolumeId != b.VolumeId {
return int(a.VolumeId - b.VolumeId)
}
return int(a.ShardId - b.ShardId)
})
return true
}

View File

@@ -400,8 +400,8 @@ func (s *Store) EcVolumes() (ecVolumes []*erasure_coding.EcVolume) {
}
location.ecVolumesLock.RUnlock()
}
slices.SortFunc(ecVolumes, func(a, b *erasure_coding.EcVolume) bool {
return a.VolumeId > b.VolumeId
slices.SortFunc(ecVolumes, func(a, b *erasure_coding.EcVolume) int {
return int(b.VolumeId - a.VolumeId)
})
return ecVolumes
}