mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-20 21:14:25 +02:00
fix(ec): detect truncated .ecx instead of treating it as clean EOF (#10217)
This commit is contained in:
1 parent
2480c2521a
commit
1d8a6e832c
2 files changed
+23
-6
No files matched your search
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user