quick slice sorting fix
This commit is contained in:
@@ -65,15 +65,26 @@ func (z *ZurgConfigV1) GetGroupMap() map[string][]string {
|
||||
groupOrderMap[val.Group] = val.GroupOrder
|
||||
}
|
||||
|
||||
// Sort the slice based on GroupOrder
|
||||
// Sort the slice based on GroupOrder and then directory name for deterministic order
|
||||
for group, dirs := range groupMap {
|
||||
sort.Slice(dirs, func(i, j int) bool {
|
||||
return groupOrderMap[dirs[i]] < groupOrderMap[dirs[j]]
|
||||
if groupOrderMap[dirs[i]] == groupOrderMap[dirs[j]] {
|
||||
return dirs[i] > dirs[j] // Use directory name as secondary sort criterion
|
||||
}
|
||||
return groupOrderMap[dirs[i]] > groupOrderMap[dirs[j]]
|
||||
})
|
||||
groupMap[group] = dirs
|
||||
}
|
||||
|
||||
return groupMap
|
||||
// Return a deep copy of the map
|
||||
result := make(map[string][]string)
|
||||
for k, v := range groupMap {
|
||||
temp := make([]string, len(v))
|
||||
copy(temp, v)
|
||||
result[k] = temp
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (z *ZurgConfigV1) MeetsConditions(directory, torrentID, torrentName string, fileNames []string) bool {
|
||||
|
||||
Reference in New Issue
Block a user