# HG changeset patch # User Kim Alvefur # Date 1345850501 -7200 # Node ID dddbcd62183a39dbdbb0599e1cca4e9f8f4260ed # Parent e646c849d72f5841af19d5b63a30d0ea301642e5 util.datamanager: Collect errors when deleting all stores of a user, but ignore "no such file" diff -r e646c849d72f -r dddbcd62183a util/datamanager.lua --- a/util/datamanager.lua Sat Aug 25 01:20:13 2012 +0200 +++ b/util/datamanager.lua Sat Aug 25 01:21:41 2012 +0200 @@ -312,15 +312,17 @@ function purge(username, host) local host_dir = format("%s/%s/", data_path, encode(host)); local deleted = 0; + local errs = {}; for file in lfs.dir(host_dir) do if lfs.attributes(host_dir..file, "mode") == "directory" then local store = decode(file); - deleted = deleted + (os_remove(getpath(username, host, store)) and 1 or 0); - deleted = deleted + (os_remove(getpath(username, host, store, "list")) and 1 or 0); - -- We this will generate loads of "No such file or directory", but do we care? + local ok, err = os_remove(getpath(username, host, store)); + if not ok and not err:lower():match("no such") then errs[#errs+1] = err; end + local ok, err = os_remove(getpath(username, host, store, "list")); + if not ok and not err:lower():match("no such") then errs[#errs+1] = err; end end end - return deleted > 0, deleted; + return #errs == 0, t_concat(errs, ", "); end return _M;