From: Štěpán Balážik Date: Wed, 1 Feb 2017 14:19:56 +0000 (+0100) Subject: lua sandbox: fix syntactic sugar for `cache` table in order for tab-completion to... X-Git-Tag: v1.3.0~23^2~86^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9027b76d031d58f65f4773b2ea3112b16b0a5feb;p=thirdparty%2Fknot-resolver.git lua sandbox: fix syntactic sugar for `cache` table in order for tab-completion to work properly --- diff --git a/daemon/lua/sandbox.lua b/daemon/lua/sandbox.lua index 743dfaa0e..feb57e33d 100644 --- a/daemon/lua/sandbox.lua +++ b/daemon/lua/sandbox.lua @@ -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)