From: Tobias Ulmer Date: Wed, 20 Nov 2013 15:48:36 +0000 (+0100) Subject: Use hash module to calculate sha1 sum X-Git-Tag: e2factory-2.3.15rc1~358 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=edfde7a23af1e81190380e8520f3d7b7ac39fc85;p=e2factory.git Use hash module to calculate sha1 sum Signed-off-by: Tobias Ulmer --- diff --git a/local/e2tool.lua b/local/e2tool.lua index 4a4c231..89d0583 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -2023,7 +2023,7 @@ end -- @return bool -- @return an error object on failure local function verify_remote_fileid(info, file, fileid) - local rc, re + local rc, re, hc local e = err.new("error calculating remote file id for file: %s:%s", file.server, file.location) if not info.cache:cache_enabled(file.server) or @@ -2075,7 +2075,15 @@ local function verify_remote_fileid(info, file, fileid) return nil, e:cat("parsing sha1sum output failed") end elseif u.transport == "file" then - remote_fileid, re = e2lib.sha1sum("/" .. u.path) + hc, re = hash.hash_start() + if not hc then + return false, e:cat(re) + end + rc, re = hash.hash_file(hc, e2lib.join("/", u.path)) + if not rc then + return false, e:cat(re) + end + remote_fileid, re = hash.hash_finish(hc) if not remote_fileid then return false, e:cat(re) end @@ -2096,7 +2104,15 @@ local function verify_remote_fileid(info, file, fileid) return false, e:cat(re) end - remote_fileid, re = e2lib.sha1sum(tmpfile) + hc, re = hash.hash_start() + if not hc then + return false, e:cat(re) + end + rc, re = hash.hash_file(hc, tmpfile) + if not rc then + return false, e:cat(re) + end + remote_fileid, re = hash.hash_finish(hc) if not remote_fileid then return false, e:cat(re) end