diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2013-12-13 14:56:23 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-12-13 14:56:23 -0200 |
| commit | 346a73b842cc352edaf4563bd61a2ba1aa2db9be (patch) | |
| tree | a78f6f145637a23108f07e89146dd46c94ab5e2e /src | |
| parent | 5ca108f27d4a4a6dce188a3c22ba0584ece1666c (diff) | |
| download | luarocks-346a73b842cc352edaf4563bd61a2ba1aa2db9be.tar.gz luarocks-346a73b842cc352edaf4563bd61a2ba1aa2db9be.tar.bz2 luarocks-346a73b842cc352edaf4563bd61a2ba1aa2db9be.zip | |
Propagate failure of MD5 correctly. Closes #184.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/fs/lua.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/fs/unix/tools.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/fs/win32/tools.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/manif.lua | 6 |
4 files changed, 8 insertions, 4 deletions
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 | |||
| 652 | function get_md5(file) | 652 | function get_md5(file) |
| 653 | file = fs.absolute_name(file) | 653 | file = fs.absolute_name(file) |
| 654 | local file = io.open(file, "rb") | 654 | local file = io.open(file, "rb") |
| 655 | if not file then return nil, "Failed to compute MD5 hash for file "..file end | 655 | if not file then return nil, "Failed to open file for reading: "..file end |
| 656 | local computed = md5.sumhexa(file:read("*a")) | 656 | local computed = md5.sumhexa(file:read("*a")) |
| 657 | file:close() | 657 | file:close() |
| 658 | if computed then return computed end | 658 | 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 = { | |||
| 324 | -- @return string: The MD5 checksum | 324 | -- @return string: The MD5 checksum |
| 325 | function get_md5(file) | 325 | function get_md5(file) |
| 326 | local cmd = md5_cmd[cfg.md5checker] | 326 | local cmd = md5_cmd[cfg.md5checker] |
| 327 | if not cmd then return nil end | 327 | if not cmd then return nil, "no MD5 checker command configured" end |
| 328 | local pipe = io.popen(cmd.." "..fs.absolute_name(file)) | 328 | local pipe = io.popen(cmd.." "..fs.absolute_name(file)) |
| 329 | local computed = pipe:read("*a") | 329 | local computed = pipe:read("*a") |
| 330 | pipe:close() | 330 | 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 = { | |||
| 344 | -- @return string: The MD5 checksum or nil + message | 344 | -- @return string: The MD5 checksum or nil + message |
| 345 | function get_md5(file) | 345 | function get_md5(file) |
| 346 | local cmd = md5_cmd[cfg.md5checker] | 346 | local cmd = md5_cmd[cfg.md5checker] |
| 347 | if not cmd then return nil end | 347 | if not cmd then return nil, "no MD5 checker command configured" end |
| 348 | local pipe = io.popen(cmd.." "..fs.Q(fs.absolute_name(file))) | 348 | local pipe = io.popen(cmd.." "..fs.Q(fs.absolute_name(file))) |
| 349 | local computed = pipe:read("*a") | 349 | local computed = pipe:read("*a") |
| 350 | pipe:close() | 350 | 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) | |||
| 73 | walk = next | 73 | walk = next |
| 74 | end | 74 | end |
| 75 | if fs.is_file(full_path) then | 75 | if fs.is_file(full_path) then |
| 76 | last[last_name] = fs.get_md5(full_path) | 76 | local sum, err = fs.get_md5(full_path) |
| 77 | if not sum then | ||
| 78 | return nil, "Failed producing checksum: "..tostring(err) | ||
| 79 | end | ||
| 80 | last[last_name] = sum | ||
| 77 | end | 81 | end |
| 78 | end | 82 | end |
| 79 | local rock_manifest = { rock_manifest=tree } | 83 | local rock_manifest = { rock_manifest=tree } |
