Fix file name could not be searched if the file was not a text file when using the Bleve indexer (#33959)

Close #33828

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
(cherry picked from commit b956cee06f462c4f34a7911351b7c878ce890725)
This commit is contained in:
charles 2025-03-22 03:00:02 +08:00 committed by Gusted
parent 839739fb71
commit 9d8624f341
No known key found for this signature in database
GPG key ID: FD821B732837125F

View file

@ -179,7 +179,8 @@ func (b *Indexer) addUpdate(ctx context.Context, batchWriter git.WriteCloserErro
return err return err
} else if !typesniffer.DetectContentType(fileContents).IsText() { } else if !typesniffer.DetectContentType(fileContents).IsText() {
// FIXME: UTF-16 files will probably fail here // FIXME: UTF-16 files will probably fail here
return nil // 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.
fileContents = nil
} }
if _, err = batchReader.Discard(1); err != nil { if _, err = batchReader.Discard(1); err != nil {