]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lua sandbox: fix syntactic sugar for `cache` table in order for tab-completion to...
authorŠtěpán Balážik <stepan.balazik@nic.cz>
Wed, 1 Feb 2017 14:19:56 +0000 (15:19 +0100)
committerŠtěpán Balážik <stepan.balazik@nic.cz>
Fri, 3 Feb 2017 18:29:16 +0000 (19:29 +0100)
daemon/lua/sandbox.lua

index 743dfaa0edd087734344275a629aa8cc1098340c..feb57e33d3fe1bf426ded006e14d5845a31a5481 100644 (file)
@@ -114,14 +114,18 @@ setmetatable(cache, {
                return t.count()
        end,
        __index = function (t, k)
-               return rawget(t, k) or (rawget(t, 'current_size') and t.get(k))
+               if type(k) == 'number' then
+                       return rawget(t, k) or (rawget(t, 'current_size') and t.get(k))
+               end
        end,
        __newindex = function (t,k,v)
                -- Defaults
-               local storage = rawget(t, 'current_storage')
-               if not storage then storage = 'lmdb://' end
-               local size = rawget(t, 'current_size')
-               if not size then size = 10*MB end
+               if type(k) == number then
+                       local storage = rawget(t, 'current_storage')
+                       if not storage then storage = 'lmdb://' end
+                       local size = rawget(t, 'current_size')
+                       if not size then size = 10*MB end
+               end
                -- Declarative interface for cache
                if     k == 'size'    then t.open(v, storage)
                elseif k == 'storage' then t.open(size, v)