(checksumToLocation checksumShardLocationMap, fileIntegrityInfos []fileIntegrityInfo, fileIDIndices map[fileID]int, i int, info decoderInputFileInfo)
| 359 | } |
| 360 | |
| 361 | func (d *Decoder) fillFileIntegrityInfos(checksumToLocation checksumShardLocationMap, fileIntegrityInfos []fileIntegrityInfo, fileIDIndices map[fileID]int, i int, info decoderInputFileInfo) (int, int, int, error) { |
| 362 | path := d.getFilePath(info) |
| 363 | data, err := d.fileIO.ReadFile(path) |
| 364 | if os.IsNotExist(err) { |
| 365 | fileIntegrityInfos[i].missing = true |
| 366 | return 0, 0, 0, nil |
| 367 | } else if err != nil { |
| 368 | return len(data), 0, 0, err |
| 369 | } |
| 370 | |
| 371 | hits, misses := fillShardInfos(d.sliceByteCount, data, checksumToLocation, info.fileID, fileIntegrityInfos, fileIDIndices) |
| 372 | |
| 373 | hashMismatch := sixteenKHash(data) != info.sixteenKHash || md5.Sum(data) != info.hash |
| 374 | fileIntegrityInfos[i].hashMismatch = hashMismatch |
| 375 | if hashMismatch { |
| 376 | d.delegate.OnDetectDataFileHashMismatch(info.fileID, path) |
| 377 | } |
| 378 | |
| 379 | hasWrongByteCount := len(data) != info.byteCount |
| 380 | fileIntegrityInfos[i].hasWrongByteCount = hasWrongByteCount |
| 381 | if hasWrongByteCount { |
| 382 | d.delegate.OnDetectDataFileWrongByteCount(info.fileID, path) |
| 383 | } |
| 384 | |
| 385 | return len(data), hits, misses, nil |
| 386 | } |
| 387 | |
| 388 | // LoadFileData loads existing file data into memory. |
| 389 | func (d *Decoder) LoadFileData() error { |
no test coverage detected