fix(ec): detect truncated .ecx instead of treating it as clean EOF (#10217)

This commit is contained in:
qzhello authored and GitHub committed 2026-07-03 11:18:46 -07:00
1 parent 2480c2521a
commit 1d8a6e832c
2 files changed
+23 -6

No files matched your search

+7 -6
View File
@@ -150,12 +150,13 @@ func iterateEcxFile(baseFileName string, processNeedleFn func(key types.NeedleId
buf := make([]byte, types.NeedleMapEntrySize)
for {
n, err := ecxFile.Read(buf)
if n != types.NeedleMapEntrySize {
if err == io.EOF {
return nil
}
return err
// .ecx is a sealed index: a partial trailing record means corruption, not a torn append.
_, err := io.ReadFull(ecxFile, buf)
if err == io.EOF {
return nil
}
if err != nil {
return fmt.Errorf("read ecx %s.ecx: %w", baseFileName, err)
}
key, offset, size := idx.IdxFileEntry(buf)
if processNeedleFn != nil {