Danek Duvall wrote:
On Tue, Feb 10, 2009 at 03:48:36PM -0600, Shawn Walker wrote:

I'm not sure how the seek/tell dance could be accomplished to calculate a hash at first glance,

Sorry; I must have gotten mixed up -- it would be a way to set the size of
/dev/null to zero without having to stat it or read its data, not to
compute the hash.

although calculating file size makes sense.

What about this?

        fhash = sha.new()
        while length > 0:
                data = f.read(min(bufsz, length))
                fhash.update(data)
                l = len(data)
                if l == 0:
                        length = 0
                else:
                        length -= l
        f.close()

Won't that still loop forever?  Perhaps you meant "if l == 0: break"?

No, given that it is in a while length > 0 loop :-)

I've tested this already.

Explicitly setting pkg.size for /dev/null may still be the way to go.

Maybe both changes should be made. The above change helps when we hit the end of a file sooner than expected...

--
Shawn Walker
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to