[FR] Support zoekt indexing of binary files
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start with IndexBuilder.Add and DocChecker.Check in indexbuilder.go, especially their null-byte checks and skip-marker handling. First determine the intended behavior for PDFs and other binary files; done should include an agreed indexing approach and tests showing the desired result without incorrectly treating binary content as text.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When trying to index binary files (like PDFs), they are skipped with the following reason: binary content at byte offset x. Seems like binary files with a byte offset don't play nice with zoekt for whatever reason.
Diagnosing with Ask:
You're absolutely correct! The primary reason PDFs and other binary files are skipped is because they contain null bytes (0x00), not just because of size limits or trigram counts.
The Null Byte Check
In IndexBuilder.Add() indexbuilder.go:428-431:
if idx := bytes.IndexByte(doc.Content, 0); idx >= 0 {
doc.SkipReason = fmt.Sprintf("binary content at byte offset %d", idx)
doc.Language = "binary"
}
This checks if there's a null byte anywhere in the file content. If found, it:
- Sets the
SkipReasonto indicate where the binary content was detected - Marks the language as "binary"
Then the content is replaced indexbuilder.go:433-440:
if doc.SkipReason != "" {
doc.Content = []byte(notIndexedMarker + doc.SkipReason)
doc.Symbols = nil
doc.SymbolsMetaData = nil
if doc.Language == "" {
doc.Language = "skipped"
}
}
The file content is replaced with a marker string like "NOT-INDEXED: binary content at byte offset 5" indexbuilder.go:386.
Similar Check in DocChecker
The DocChecker.Check() method has an identical check indexbuilder.go:544-546:
if index := bytes.IndexByte(content, 0); index > 0 {
return fmt.Errorf("binary data at byte offset %d", index)
}
Bottom line: PDFs cannot be indexed in Zoekt because they contain null bytes, which are fundamental to binary file formats. The presence of even a single null byte causes the file to be marked as binary and excluded from text-based indexing. There's no configuration option to override this behavior since Zoekt is designed specifically for text-based source code search.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.9k
- Fork
- 374
- Merge trung bình
- 21 giờ 18 phút
- Pull request đã merge (30 ngày)
- 39
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sourcebot-dev/sourcebot
-
bug triage needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
sourcebot-dev/sourcebot#1681 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
sourcebot-dev/sourcebot#1633 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
sourcebot-dev/sourcebot#1384 · 4 bình luận ·
-
ask_sb bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
sourcebot-dev/sourcebot#1137 · 4 bình luận ·
-
bug triage needed
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
sourcebot-dev/sourcebot#1661 · 1 bình luận ·
Tất cả issue của sourcebot-dev/sourcebot
Issue tương tự
-
blocklist removal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
MetaMask/eth-phishing-detect#296544 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
pastelsky/bundlephobia#1122 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100