util.datamanager: Fix traceback from trying to purge when storage is empty or otherwi...
authorKim Alvefur <zash@zash.se>
Wed, 13 May 2015 19:44:13 +0000 (21:44 +0200)
committerKim Alvefur <zash@zash.se>
Wed, 13 May 2015 19:44:13 +0000 (21:44 +0200)
util/datamanager.lua

index b4138638f790b437bd85d2caf5b91588a53933d2..a107d95c26904a697a949157f8caa706ca46a696 100644 (file)
@@ -348,8 +348,12 @@ end
 
 function purge(username, host)
        local host_dir = format("%s/%s/", data_path, encode(host));
+       local ok, iter, state, var = pcall(lfs.dir, host_dir);
+       if not ok then
+               return ok, iter;
+       end
        local errs = {};
-       for file in lfs.dir(host_dir) do
+       for file in iter, state, var do
                if lfs.attributes(host_dir..file, "mode") == "directory" then
                        local store = decode(file);
                        local ok, err = do_remove(getpath(username, host, store));