From: Tobias Ulmer Date: Thu, 2 Aug 2012 15:29:17 +0000 (+0200) Subject: Remove defect call to sha1sum and replace it with hash_file() X-Git-Tag: e2factory-2.3.13rc1~216 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=d300342332aabd067ccd00396acb9d46df53a712;p=e2factory.git Remove defect call to sha1sum and replace it with hash_file() Signed-off-by: Tobias Ulmer --- diff --git a/local/e2tool.lua b/local/e2tool.lua index bfe05b9..70b79e4 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -1005,20 +1005,19 @@ end -- @return string the hash value, nil on error -- @return nil, an error string on error function hash_path(path) - local f = io.popen(string.format("sha1sum %s", e2lib.shquote(path)), "r") - if not f then - return false, "can't calculation checksum" - end - local l = f:read("*l") - f:close() - if not l then - return nil, "can't calculation checksum" - end - local s, e, cs, b = string.find(l, "^(%S+)%s+(%S+)$") - if not cs then - return nil, "can't calculation checksum" + assert(type(path) == "string") + assert(string.len(path) > 0) + + local e = new_error("error hashing path") + + local ctx = hash.hash_start() + + local rc, re = ctx:hash_file(path) + if not rc then + return nil, e:cat(re) end - return cs + + return ctx:hash_finish() end --- hash a file addressed by server name and location