From 9027b76d031d58f65f4773b2ea3112b16b0a5feb Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=A0t=C4=9Bp=C3=A1n=20Bal=C3=A1=C5=BEik?= Date: Wed, 1 Feb 2017 15:19:56 +0100 Subject: [PATCH] lua sandbox: fix syntactic sugar for `cache` table in order for tab-completion to work properly --- daemon/lua/sandbox.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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) -- 2.47.2