Skip to content
Snippets Groups Projects
Commit d5272b4b authored by Marek Vavruša's avatar Marek Vavruša
Browse files

daemon/bindings: metatable wasn’t called on cache.{storage|size}

the bindings wrote the keys on completion, so they existed
and __newindex was never called - now current {storage|size}
are saved as cache.current_{storage|size}
parent 587450c7
No related branches found
No related tags found
No related merge requests found
......@@ -382,10 +382,10 @@ static int cache_open(lua_State *L)
/* Store current configuration */
lua_getglobal(L, "cache");
lua_pushstring(L, "size");
lua_pushstring(L, "current_size");
lua_pushnumber(L, cache_size);
lua_rawset(L, -3);
lua_pushstring(L, "storage");
lua_pushstring(L, "current_storage");
lua_pushstring(L, uri);
lua_rawset(L, -3);
......
......@@ -52,8 +52,8 @@ setmetatable(modules, {
-- `cache.{size|storage} = value`
setmetatable(cache, {
__newindex = function (t,k,v)
if k == 'size' then t.open(v, rawget(t, 'storage'))
elseif k == 'storage' then t.open(rawget(t, 'size'), v)
if k == 'size' then t.open(v, rawget(t, 'current_storage'))
elseif k == 'storage' then t.open(rawget(t, 'current_size'), v)
else rawset(t, k, v) end
end
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment