I came across an issue with the following piece of code. I want to simply generate the md5 of a file. I want to use the Unix utility md5sum to spit out the hash so I can capture it.
The problem I'm having is that occasionally, maybe 1 in 10 times I run this script, I get an empty string from the buffer. There's some race condition here, but I don't know if it's from using the process or the buffer, or if it's a bug on Fan's side.
class Test
{
Void main()
{
p := Process(["md5sum", "Test.fan"])
buf := Buf()
p.out = buf.out
echo("Return code: " + p.run.join)
buf.seek(0)
str := buf.readAllStr
echo(str)
echo(str.size)
}
}
brianSun 4 Oct 2009
@tatics
thanks for reporting that
can you try out this patch and see if that fixes your problem?
DubheadMon 5 Oct 2009
Off topic, but just in case you aren't aware of this: You can generate MD5 with sys::Buf#hmac.
tactics Sat 3 Oct 2009
I came across an issue with the following piece of code. I want to simply generate the md5 of a file. I want to use the Unix utility md5sum to spit out the hash so I can capture it.
The problem I'm having is that occasionally, maybe 1 in 10 times I run this script, I get an empty string from the buffer. There's some race condition here, but I don't know if it's from using the process or the buffer, or if it's a bug on Fan's side.
brian Sun 4 Oct 2009
@tatics
thanks for reporting that
can you try out this patch and see if that fixes your problem?
Dubhead Mon 5 Oct 2009
Off topic, but just in case you aren't aware of this: You can generate MD5 with
sys::Buf#hmac
.brian Mon 5 Oct 2009
You can also use
sys::Buf.toDigest