Skip to content

Commit 9d8624f

Browse files
charles7668wxiaoguang
authored andcommitted
Fix file name could not be searched if the file was not a text file when using the Bleve indexer (go-gitea#33959)
Close go-gitea#33828 --------- Co-authored-by: wxiaoguang <[email protected]> (cherry picked from commit b956cee)
1 parent 839739f commit 9d8624f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/indexer/code/bleve/bleve.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ func (b *Indexer) addUpdate(ctx context.Context, batchWriter git.WriteCloserErro
179179
return err
180180
} else if !typesniffer.DetectContentType(fileContents).IsText() {
181181
// FIXME: UTF-16 files will probably fail here
182-
return nil
182+
// Even if the file is not recognized as a "text file", we could still put its name into the indexers to make the filename become searchable, while leave the content to empty.
183+
fileContents = nil
183184
}
184185

185186
if _, err = batchReader.Discard(1); err != nil {

0 commit comments

Comments
 (0)