11
type DelExtFile []os.FileInfo
13
func (del DelExtFile) Len() int {
17
func (del DelExtFile) Swap(i, j int) {
18
del[i], del[j] = del[j], del[i]
21
func (del DelExtFile) Less(i, j int) bool {
22
idx1 := getDelExtFileIdx(del[i].Name())
23
idx2 := getDelExtFileIdx(del[j].Name())
28
func getDelExtFileIdx(name string) int64 {
29
arr := strings.Split(name, "_")
32
panic(fmt.Errorf("file name is not legal, %s", name))
35
idx, err := strconv.ParseInt(arr[size-1], 10, 64)
37
panic(fmt.Errorf("file name is not legal, %s", name))
43
func sortDelExtFileInfo(files []os.FileInfo) []os.FileInfo {
44
newFiles := make([]os.FileInfo, 0)
46
for _, info := range files {
51
if strings.HasPrefix(info.Name(), prefixDelExtent) {
52
newFiles = append(newFiles, info)
56
if len(newFiles) <= 1 {
60
sort.Sort(DelExtFile(newFiles))