Danek Duvall wrote:
On Tue, Feb 10, 2009 at 03:05:35PM -0600, Shawn Walker wrote:
- line 122: why is this a problem?
It causes the process to hang if pkg.size isn't provided. Call this
"slap the hand of people trying to break my stuff on purpose."
How does it hang? Reading from /dev/null should return EOF immediately.
I've used this quite a bit to put dummy test files into dummy packages.
It hangs when attempting to calculate the hash in chunks. That's because
the length of the read data from /dev/null is always 0:
fhash = sha.new()
while length > 0:
data = f.read(min(bufsz, length))
fhash.update(data)
length -= len(data)
f.close()
I can't just read until EOF as that will fail if the underlying file object
is a request rfile (socket).
Why not just set pkg.size to 0 for /dev/null, then? Or let it do the
seek/tell dance, which appears to work fine on Solaris?
I'm not sure how the seek/tell dance could be accomplished to calculate
a hash at first glance, 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()
--
Shawn Walker
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss