diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-04-05 15:59:56 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-04-11 14:38:06 -0300 |
| commit | 1f213a5b07bb6c1aeff80c3bbe74b8230dd506f6 (patch) | |
| tree | 888cab550d8d7d449dc37886edd6afc0d6856e76 /src | |
| parent | 835d21e98e95e0ed2b6b028ddb06fe87427e5488 (diff) | |
| download | luarocks-1f213a5b07bb6c1aeff80c3bbe74b8230dd506f6.tar.gz luarocks-1f213a5b07bb6c1aeff80c3bbe74b8230dd506f6.tar.bz2 luarocks-1f213a5b07bb6c1aeff80c3bbe74b8230dd506f6.zip | |
Read namespace on disk search as well
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/search.lua | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index 54ddd517..a86db890 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
| @@ -47,6 +47,25 @@ local function store_if_match(result_tree, result, query) | |||
| 47 | end | 47 | end |
| 48 | end | 48 | end |
| 49 | 49 | ||
| 50 | --- Get the namespace of a locally-installed rock, if any. | ||
| 51 | -- @param name string: The rock name, without a namespace. | ||
| 52 | -- @param version string: The rock version. | ||
| 53 | -- @param tree string: The local tree to use. | ||
| 54 | -- @return string?: The namespace if it exists, or nil. | ||
| 55 | local function read_namespace(name, version, tree) | ||
| 56 | assert(type(name) == "string") | ||
| 57 | assert(type(version) == "string") | ||
| 58 | assert(type(tree) == "string") | ||
| 59 | |||
| 60 | local namespace | ||
| 61 | local fd = io.open(path.rock_namespace_file(name, version, tree), "r") | ||
| 62 | if fd then | ||
| 63 | namespace = fd:read("*a") | ||
| 64 | fd:close() | ||
| 65 | end | ||
| 66 | return namespace | ||
| 67 | end | ||
| 68 | |||
| 50 | --- Perform search on a local repository. | 69 | --- Perform search on a local repository. |
| 51 | -- @param repo string: The pathname of the local repository. | 70 | -- @param repo string: The pathname of the local repository. |
| 52 | -- @param query table: a query object. | 71 | -- @param query table: a query object. |
| @@ -77,8 +96,7 @@ function search.disk_search(repo, query, result_tree) | |||
| 77 | elseif fs.is_dir(pathname) then | 96 | elseif fs.is_dir(pathname) then |
| 78 | for version in fs.dir(pathname) do | 97 | for version in fs.dir(pathname) do |
| 79 | if version:match("-%d+$") then | 98 | if version:match("-%d+$") then |
| 80 | local namespace = nil | 99 | local namespace = read_namespace(name, version, repo) |
| 81 | -- FIXME read rock_namespace file | ||
| 82 | local result = results.new(name, version, repo, "installed", namespace) | 100 | local result = results.new(name, version, repo, "installed", namespace) |
| 83 | store_if_match(result_tree, result, query) | 101 | store_if_match(result_tree, result, query) |
| 84 | end | 102 | end |
| @@ -88,16 +106,6 @@ function search.disk_search(repo, query, result_tree) | |||
| 88 | return result_tree | 106 | return result_tree |
| 89 | end | 107 | end |
| 90 | 108 | ||
| 91 | local function read_namespace(name, version, tree) | ||
| 92 | local namespace | ||
| 93 | local fd = io.open(path.rock_namespace_file(name, version, tree), "r") | ||
| 94 | if fd then | ||
| 95 | namespace = fd:read("*a") | ||
| 96 | fd:close() | ||
| 97 | end | ||
| 98 | return namespace | ||
| 99 | end | ||
| 100 | |||
| 101 | --- Perform search on a rocks server or tree. | 109 | --- Perform search on a rocks server or tree. |
| 102 | -- @param result_tree table: The result tree, where keys are package names and | 110 | -- @param result_tree table: The result tree, where keys are package names and |
| 103 | -- values are tables matching version strings to arrays of | 111 | -- values are tables matching version strings to arrays of |
