equal
deleted
inserted
replaced
224 return nil, "Error reading storage"; |
224 return nil, "Error reading storage"; |
225 end |
225 end |
226 return items; |
226 return items; |
227 end |
227 end |
228 |
228 |
|
229 function list_stores(username, host) |
|
230 if not host then |
|
231 return nil, "bad argument #2 to 'list_stores' (string expected, got nothing)"; |
|
232 end |
|
233 local list = {}; |
|
234 local host_dir = format("%s/%s/", data_path, encode(host)); |
|
235 for node in lfs.dir(host_dir) do |
|
236 if not node:match"^%." then -- dots should be encoded, this is probably . or .. |
|
237 local store = decode(node); |
|
238 local path = host_dir..node; |
|
239 if username == true then |
|
240 if lfs.attributes(path, "mode") == "directory" then |
|
241 list[#list+1] = store; |
|
242 end |
|
243 elseif username then |
|
244 if lfs.attributes(getpath(username, host, store), "mode") |
|
245 or lfs.attributes(getpath(username, host, store, "list"), "mode") then |
|
246 list[#list+1] = store; |
|
247 end |
|
248 elseif lfs.attributes(path, "mode") == "file" then |
|
249 list[#list+1] = store:gsub("%.[dalist]+$",""); |
|
250 end |
|
251 end |
|
252 end |
|
253 return list; |
|
254 end |
|
255 |
229 return _M; |
256 return _M; |