]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
cache.clear: use same output format for full cache clear
authorPetr Špaček <petr.spacek@nic.cz>
Thu, 16 Aug 2018 15:37:02 +0000 (17:37 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 17 Aug 2018 13:58:49 +0000 (15:58 +0200)
daemon/lua/sandbox.lua

index 1768df7739520a54d6e4cfa89c39209c07c8baf2..7280bce1aa1751eadb0f41288fa02dd3b7029938 100644 (file)
@@ -159,7 +159,13 @@ setmetatable(modules, {
 
 
 cache.clear = function (name, exact_name, rr_type, chunk_size, callback)
-       if name == nil then return cache.clear_everything() end
+       if name == nil then  -- keep same output format as for 'standard' clear
+               local total_count = cache.count()
+               if not cache.clear_everything() then
+                       error('unable to clear everything')
+               end
+               return {count = total_count}
+       end
        -- Check parameters, in order, and set defaults if missing.
        local dname = kres.str2dname(name)
        if not dname then error('cache.clear(): incorrect name passed') end