Skip to content

Commit

Permalink
workaround a problem
Browse files Browse the repository at this point in the history
  • Loading branch information
sagan committed Dec 29, 2023
1 parent a47418e commit 2c0c105
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions util/torrentutil/torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,23 @@ func (meta *TorrentMeta) Verify(savePath string, contentPath string, checkHash b
} else {
filename = prefixPath + file.Path
}
mm, err := mmapFile(filename)
stat, err := os.Stat(filename)
if err != nil {
return err
return fmt.Errorf("failed to get file %s stat: %v", file.Path, err)
}
if int64(len(mm)) != file.Size {
if stat.Size() != file.Size {
return fmt.Errorf("file %q has wrong length", filename)
}
span.Append(mm)
if checkHash {
// only mmap file when necessary. Windows may throw "MapViewOfFile: The paging file is too small for this operation to complete." error
// when mmaping big torrents (when torrent content size exceeds PC memory ?).
// @todo : use more robust way to calculate hash
mm, err := mmapFile(filename)
if err != nil {
return err
}
span.Append(mm)
}
}
if checkHash {
piecesCnt := meta.Info.NumPieces()
Expand Down

0 comments on commit 2c0c105

Please sign in to comment.