]> git.e2factory.org Git - e2factory.git/commitdiff
Remove defect call to sha1sum and replace it with hash_file()
authorTobias Ulmer <tu@emlix.com>
Thu, 2 Aug 2012 15:29:17 +0000 (17:29 +0200)
committerTobias Ulmer <tu@emlix.com>
Thu, 2 Aug 2012 15:29:17 +0000 (17:29 +0200)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/e2tool.lua

index bfe05b9d9e88fcdb2648ae6e8844a5f2fdeb1a63..70b79e4a9e8de44434157608f75b36ca5ece6c23 100644 (file)
@@ -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