Skip to content

Commit 4987ecf

Browse files
committed
fix search
1 parent 5da589a commit 4987ecf

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

search/prefix_index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func compactSearchHits(hits []Hit) []Hit {
283283
}
284284

285285
last := res[len(res)-1]
286-
if hit.Score == last.Score && strings.HasPrefix(hit.Path, last.Path) {
286+
if last.IsDir && hit.Score == last.Score && strings.HasPrefix(hit.Path, last.Path) {
287287
continue
288288
}
289289
res = append(res, hit)

search/prefix_index_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,23 @@ func TestPrefixIndex(t *testing.T) {
382382
},
383383
hits,
384384
)
385+
386+
// Don't merge 'test.Dockerfile' and 'test.Dockerfile.dockerignore'
387+
entries = []rclone.DirEntry{
388+
newDirEntry("/Dockerfile", 0, 0),
389+
newDirEntry("/test.Dockerfile", 0, 0),
390+
newDirEntry("/test.Dockerfile.dockerignore", 0, 0),
391+
}
392+
index = newPrefixIndex(slices.Values(entries), 3, 7)
393+
hits, _ = index.Search(`"dockerfile"`, 10)
394+
r.Equal(
395+
[]Hit{
396+
{Path: "/Dockerfile", Score: float32(math.Inf(1))},
397+
{Path: "/test.Dockerfile", Score: float32(math.Inf(1))},
398+
{Path: "/test.Dockerfile.dockerignore", Score: float32(math.Inf(1))},
399+
},
400+
hits,
401+
)
385402
})
386403

387404
t.Run("metadata", func(t *testing.T) {

0 commit comments

Comments
 (0)