diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2010-09-13 04:30:08 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2010-09-13 04:30:08 -0300 |
commit | 340adc215813ac6a892c62f6f98f90a2479def12 (patch) | |
tree | bdf3c128fd43420c5749fbbf8eac849b1e160633 | |
parent | e775a06997f115ff021d03eb00aac6dc060e956b (diff) | |
download | luarocks-340adc215813ac6a892c62f6f98f90a2479def12.tar.gz luarocks-340adc215813ac6a892c62f6f98f90a2479def12.tar.bz2 luarocks-340adc215813ac6a892c62f6f98f90a2479def12.zip |
Improve checks, catching configuration or flag errors
-rw-r--r-- | src/luarocks/add.lua | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/luarocks/add.lua b/src/luarocks/add.lua index 0085b0cc..61d44665 100644 --- a/src/luarocks/add.lua +++ b/src/luarocks/add.lua | |||
@@ -43,20 +43,20 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
43 | end | 43 | end |
44 | 44 | ||
45 | local at = fs.current_dir() | 45 | local at = fs.current_dir() |
46 | 46 | ||
47 | local local_cache, protocol, server_path, user, password | 47 | local refresh_fn = refresh and cache.refresh_local_cache or cache.split_server_url |
48 | if refresh then | 48 | local local_cache, protocol, server_path, user, password = refresh_fn(server, download_url, cfg.upload_user, cfg.upload_password) |
49 | local_cache, protocol, server_path, user, password = cache.refresh_local_cache(server, download_url, cfg.upload_user, cfg.upload_password) | ||
50 | else | ||
51 | local_cache, protocol, server_path, user, password = cache.split_server_url(server, download_url, cfg.upload_user, cfg.upload_password) | ||
52 | end | ||
53 | if not local_cache then | 49 | if not local_cache then |
54 | return nil, protocol | 50 | return nil, protocol |
55 | end | 51 | end |
52 | if protocol == "file" then | ||
53 | return nil, "Server "..server.." is not recognized, check your configuration." | ||
54 | end | ||
55 | |||
56 | if not login_url then | 56 | if not login_url then |
57 | login_url = protocol.."://"..server_path | 57 | login_url = protocol.."://"..server_path |
58 | end | 58 | end |
59 | 59 | ||
60 | fs.change_dir(at) | 60 | fs.change_dir(at) |
61 | 61 | ||
62 | local files = {} | 62 | local files = {} |
@@ -91,10 +91,10 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
91 | -- TODO abstract away explicit 'curl' call | 91 | -- TODO abstract away explicit 'curl' call |
92 | 92 | ||
93 | local cmd | 93 | local cmd |
94 | if upload_server.rsync then | 94 | if upload_server and upload_server.rsync then |
95 | local srv, path = server_path:match("([^/]+)(/.+)") | 95 | local srv, path = server_path:match("([^/]+)(/.+)") |
96 | cmd = "rsync -Oavz -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/" | 96 | cmd = "rsync -Oavz -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/" |
97 | elseif upload_server.sftp then | 97 | elseif upload_server and upload_server.sftp then |
98 | local part1, part2 = upload_server.sftp:match("^([^/]*)/(.*)$") | 98 | local part1, part2 = upload_server.sftp:match("^([^/]*)/(.*)$") |
99 | cmd = "scp manifest index.html "..table.concat(files, " ").." "..user.."@"..part1..":/"..part2 | 99 | cmd = "scp manifest index.html "..table.concat(files, " ").." "..user.."@"..part1..":/"..part2 |
100 | else | 100 | else |
@@ -118,6 +118,7 @@ function run(...) | |||
118 | if not server then | 118 | if not server then |
119 | return nil, "No server specified with --to and no default configured with upload_server." | 119 | return nil, "No server specified with --to and no default configured with upload_server." |
120 | end | 120 | end |
121 | |||
121 | return add_files_to_server(not flags["no-refresh"], files, server, cfg.upload_servers and cfg.upload_servers[server]) | 122 | return add_files_to_server(not flags["no-refresh"], files, server, cfg.upload_servers and cfg.upload_servers[server]) |
122 | end | 123 | end |
123 | 124 | ||