From 346a73b842cc352edaf4563bd61a2ba1aa2db9be Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 13 Dec 2013 14:56:23 -0200 Subject: Propagate failure of MD5 correctly. Closes #184. --- src/luarocks/fs/lua.lua | 2 +- src/luarocks/fs/unix/tools.lua | 2 +- src/luarocks/fs/win32/tools.lua | 2 +- src/luarocks/manif.lua | 6 +++++- 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 5f7d6c37..94095004 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -652,7 +652,7 @@ if md5_ok then function get_md5(file) file = fs.absolute_name(file) local file = io.open(file, "rb") - if not file then return nil, "Failed to compute MD5 hash for file "..file end + if not file then return nil, "Failed to open file for reading: "..file end local computed = md5.sumhexa(file:read("*a")) file:close() if computed then return computed end diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index c857b093..5495760b 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua @@ -324,7 +324,7 @@ local md5_cmd = { -- @return string: The MD5 checksum function get_md5(file) local cmd = md5_cmd[cfg.md5checker] - if not cmd then return nil end + if not cmd then return nil, "no MD5 checker command configured" end local pipe = io.popen(cmd.." "..fs.absolute_name(file)) local computed = pipe:read("*a") pipe:close() diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index 0ec46314..345ec682 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua @@ -344,7 +344,7 @@ local md5_cmd = { -- @return string: The MD5 checksum or nil + message function get_md5(file) local cmd = md5_cmd[cfg.md5checker] - if not cmd then return nil end + if not cmd then return nil, "no MD5 checker command configured" end local pipe = io.popen(cmd.." "..fs.Q(fs.absolute_name(file))) local computed = pipe:read("*a") pipe:close() diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 1c7707a9..238c4056 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua @@ -73,7 +73,11 @@ function make_rock_manifest(name, version) walk = next end if fs.is_file(full_path) then - last[last_name] = fs.get_md5(full_path) + local sum, err = fs.get_md5(full_path) + if not sum then + return nil, "Failed producing checksum: "..tostring(err) + end + last[last_name] = sum end end local rock_manifest = { rock_manifest=tree } -- cgit v1.2.3-55-g6feb