freebsd/pkg — pull request #794 by namore (2014-05-05 21:15:01+00:00)
Title: Reducing checksum overhead.

Full description:
When downloading a package, pkg first checks whether the file exists
in the cache directory. The cached file may be old or corrupted,
therefore pkg computes an sha256 checksum of the cached file and
compares it to the known checksum of the repository before using the
cached file.
Computing the checksum is expensive and can take several seconds for
large packages. During a pkg-upgrade on a system with several
packages, checksums for hundreds or even thousands of megabytes will
be calculated.
This commit adds a simple check of the size of the cached file before
calculating it's checksum. Files of differenz size should not produce
the same hash from a collision resistant hash function, so it is safe
to assume that the checksums will be different if the size differs.