diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2018-11-12 11:35:43 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-11-12 11:40:54 -0200 |
commit | dc46a813a8966dc9570018969c1702a0e6a85e05 (patch) | |
tree | b2f18e09021bc1c0d1e135d5f69a9135ac360146 | |
parent | aafc594d96d306dc999b3bb39b98d1e686beef71 (diff) | |
download | luarocks-dc46a813a8966dc9570018969c1702a0e6a85e05.tar.gz luarocks-dc46a813a8966dc9570018969c1702a0e6a85e05.tar.bz2 luarocks-dc46a813a8966dc9570018969c1702a0e6a85e05.zip |
only report on local cache ownership if we can check it
Closes #901.
-rw-r--r-- | src/luarocks/cmd.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 996900ff..ea906726 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -25,6 +25,9 @@ cmd.errorcodes = { | |||
25 | 25 | ||
26 | local function is_ownership_ok(directory) | 26 | local function is_ownership_ok(directory) |
27 | local me = fs.current_user() | 27 | local me = fs.current_user() |
28 | if not me then | ||
29 | return nil, "can't determine current user's name" | ||
30 | end | ||
28 | for _ = 1,3 do -- try up to grandparent | 31 | for _ = 1,3 do -- try up to grandparent |
29 | local owner = fs.attributes(directory, "owner") | 32 | local owner = fs.attributes(directory, "owner") |
30 | if owner then | 33 | if owner then |
@@ -468,7 +471,8 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
468 | end | 471 | end |
469 | end | 472 | end |
470 | 473 | ||
471 | if not is_ownership_ok(cfg.local_cache) then | 474 | local user_owns_local_cache = is_ownership_ok(cfg.local_cache) |
475 | if user_owns_local_cache == false then | ||
472 | util.warning("The directory '" .. cfg.local_cache .. "' or its parent directory ".. | 476 | util.warning("The directory '" .. cfg.local_cache .. "' or its parent directory ".. |
473 | "is not owned by the current user and the cache has been disabled. ".. | 477 | "is not owned by the current user and the cache has been disabled. ".. |
474 | "Please check the permissions and owner of that directory. ".. | 478 | "Please check the permissions and owner of that directory. ".. |