Mercurial > prosody-hg
comparison util/datamanager.lua @ 7674:8027eecc750f
util.datamanager: Add annotations to ignore name clashes [luacheck]
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 24 Sep 2016 18:31:16 +0200 |
| parents | 177d569307fd |
| children | aba3dd84d9f0 |
comparison
equal
deleted
inserted
replaced
| 7673:177d569307fd | 7674:8027eecc750f |
|---|---|
| 319 local type_map = { | 319 local type_map = { |
| 320 keyval = "dat"; | 320 keyval = "dat"; |
| 321 list = "list"; | 321 list = "list"; |
| 322 } | 322 } |
| 323 | 323 |
| 324 local function users(host, store, typ) | 324 local function users(host, store, typ) -- luacheck: ignore 431/store |
| 325 typ = type_map[typ or "keyval"]; | 325 typ = type_map[typ or "keyval"]; |
| 326 local store_dir = format("%s/%s/%s", data_path, encode(host), store); | 326 local store_dir = format("%s/%s/%s", data_path, encode(host), store); |
| 327 | 327 |
| 328 local mode, err = lfs.attributes(store_dir, "mode"); | 328 local mode, err = lfs.attributes(store_dir, "mode"); |
| 329 if not mode then | 329 if not mode then |
| 330 return function() log("debug", "%s", err or (store_dir .. " does not exist")) end | 330 return function() log("debug", "%s", err or (store_dir .. " does not exist")) end |
| 331 end | 331 end |
| 332 local next, state = lfs.dir(store_dir); | 332 local next, state = lfs.dir(store_dir); -- luacheck: ignore 431/next 431/state |
| 333 return function(state) | 333 return function(state) -- luacheck: ignore 431/state |
| 334 for node in next, state do | 334 for node in next, state do |
| 335 local file, ext = node:match("^(.*)%.([dalist]+)$"); | 335 local file, ext = node:match("^(.*)%.([dalist]+)$"); |
| 336 if file and ext == typ then | 336 if file and ext == typ then |
| 337 return decode(file); | 337 return decode(file); |
| 338 end | 338 end |
| 346 | 346 |
| 347 local mode, err = lfs.attributes(store_dir, "mode"); | 347 local mode, err = lfs.attributes(store_dir, "mode"); |
| 348 if not mode then | 348 if not mode then |
| 349 return function() log("debug", err or (store_dir .. " does not exist")) end | 349 return function() log("debug", err or (store_dir .. " does not exist")) end |
| 350 end | 350 end |
| 351 local next, state = lfs.dir(store_dir); | 351 local next, state = lfs.dir(store_dir); -- luacheck: ignore 431/next 431/state |
| 352 return function(state) | 352 return function(state) -- luacheck: ignore 431/state |
| 353 for node in next, state do | 353 for node in next, state do |
| 354 if not node:match"^%." then | 354 if not node:match"^%." then |
| 355 if username == true then | 355 if username == true then |
| 356 if lfs.attributes(store_dir..node, "mode") == "directory" then | 356 if lfs.attributes(store_dir..node, "mode") == "directory" then |
| 357 return decode(node); | 357 return decode(node); |
