Closed bayrinat closed 7 years ago
If you only need the checksum and size of a file, I would instead recommend using methods in the standard libraries as you would for any other file type. The file size should be available as a Content-Length
HTTP header and you can use io.Copy
to read a response body into a Hash
.
The ReadPackageFile
method deliberately does not compute any checksums for the following reasons:
Hash
ReadPackageFile
only reads the file headers - consider that some RPM files can be > 1GB while most headers are a few kilobytesI agree, rpm could be too large for processing in ReadPackageFile
.
Then separated methods for Checksum and Size from stream are expected. Now Checksum()
returns error for pack from reader
and this is confusing a little bit.
I'll update the documentation to make this clearer. PackageFile.Size specifies the disk space consumed by installation of the package, not the size of the package file. See PackageFile.FileSize instead.
That said, FileSize, Checksum, etc. all expect a local file and return zero-values for packages read from an io.Reader
. I'll make sure the docs reflect this.
ok, thanks.
I need to get package from remote repository. ReadPackageFile(r io.Reader) allows me to get all needed data instead of checksum and size. Now I fix it by using ioutil.ReadAll(). I simply calculate checksum and get size.
I think, method with reading stream should do it inside.