fix(flashnode): check file length using allocated size #1000150848

Signed-off-by: clinx <chenlin1@oppo.com>

(cherry picked from commit c094de085f)
This commit is contained in:
clinx 2025-06-19 10:43:51 +08:00 committed by chihe
parent 7a02e89572
commit 64b8dbf0c6

View File

@ -291,8 +291,8 @@ func (cb *CacheBlock) checkCacheBlockFileHeader(file *os.File, sourceType string
return
} else if SourceTypeBlock == sourceType {
crcSize := (usedSize + proto.PageSize - 1) / proto.PageSize * CRCLen
if usedSize+HeaderSize+crcSize != stat.Size() {
err = fmt.Errorf("usedSize + headerSize + crsSize [%v] != file real size[%v]", usedSize+HeaderSize+crcSize, stat.Size())
if allocSize+HeaderSize+crcSize != stat.Size() {
err = fmt.Errorf("allocSize + headerSize + crsSize [%v] != file real size[%v]", allocSize+HeaderSize+crcSize, stat.Size())
return
}
}