Software /
code /
prosody
Comparison
util/datamanager.lua @ 6681:0217a04722c7
util.datamanager: Fix traceback from trying to purge when storage is empty or otherwise unaccessible (fixes #496)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 13 May 2015 21:44:13 +0200 |
parent | 6644:6cb6855f60df |
child | 6777:5de6b93d0190 |
child | 7200:67ac4a0b6e50 |
comparison
equal
deleted
inserted
replaced
6680:ae34b12c4335 | 6681:0217a04722c7 |
---|---|
346 return true | 346 return true |
347 end | 347 end |
348 | 348 |
349 function purge(username, host) | 349 function purge(username, host) |
350 local host_dir = format("%s/%s/", data_path, encode(host)); | 350 local host_dir = format("%s/%s/", data_path, encode(host)); |
351 local ok, iter, state, var = pcall(lfs.dir, host_dir); | |
352 if not ok then | |
353 return ok, iter; | |
354 end | |
351 local errs = {}; | 355 local errs = {}; |
352 for file in lfs.dir(host_dir) do | 356 for file in iter, state, var do |
353 if lfs.attributes(host_dir..file, "mode") == "directory" then | 357 if lfs.attributes(host_dir..file, "mode") == "directory" then |
354 local store = decode(file); | 358 local store = decode(file); |
355 local ok, err = do_remove(getpath(username, host, store)); | 359 local ok, err = do_remove(getpath(username, host, store)); |
356 if not ok then errs[#errs+1] = err; end | 360 if not ok then errs[#errs+1] = err; end |
357 | 361 |