Skip to content

Commit

Permalink
refactor(backend/teldrive): remove sorting of duplicate objects by mo…
Browse files Browse the repository at this point in the history
…dification time
  • Loading branch information
bhunter234 committed Jan 24, 2025
1 parent ef07291 commit 3186a56
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions backend/teldrive/teldrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"net/http"
"net/url"
"path"
"sort"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -524,12 +523,7 @@ func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error) {
if res[0].Type == "folder" {
return nil, fs.ErrorIsDir
}
//In case of duplicates take the latest one
if len(res) > 1 {
sort.Slice(res, func(i, j int) bool {
return res[i].ModTime.After(res[j].ModTime)
})
}

return f.newObjectWithInfo(ctx, remote, &res[0])
}

Expand All @@ -541,6 +535,8 @@ func (f *Fs) findObject(ctx context.Context, pathID, leaf string) ([]api.FileInf
"parentId": []string{pathID},
"operation": []string{"find"},
"name": []string{leaf},
"sort": []string{"id"},
"order": []string{"desc"},
},
}
var info api.ReadMetadataResponse
Expand Down

0 comments on commit 3186a56

Please sign in to comment.