# HG changeset patch # User Matthew Wild # Date 1324463117 0 # Node ID 3d3687fef75186328daa2788919cf910385ca0af # Parent e98fe28c50b0d80ac7eb65a0b93a89a3dea09db7 mod_pastebin: Fix issue with metatable not being set when a reload changes expires_after to 0 diff -r e98fe28c50b0 -r 3d3687fef751 mod_pastebin/mod_pastebin.lua --- a/mod_pastebin/mod_pastebin.lua Tue Dec 20 20:19:53 2011 +0000 +++ b/mod_pastebin/mod_pastebin.lua Wed Dec 21 10:25:17 2011 +0000 @@ -44,24 +44,6 @@ local xmlns_xhtmlim = "http://jabber.org/protocol/xhtml-im"; local xmlns_xhtml = "http://www.w3.org/1999/xhtml"; -if expire_after == 0 then - local dm = require "util.datamanager"; - setmetatable(pastes, { - __index = function (pastes, id) - if type(id) == "string" then - return dm.load(id, module.host, "pastebin"); - end - end; - __newindex = function (pastes, id, data) - if type(id) == "string" then - dm.store(id, module.host, "pastebin", data); - end - end; - }); -else - setmetatable(pastes, nil); -end - function pastebin_text(text) local uuid = uuid_new(); pastes[uuid] = { body = text, time = os_time(), headers = default_headers }; @@ -161,6 +143,26 @@ httpserver.new{ port = port, base = base, handler = handle_request, ssl = ssl } end +function module.load() + if expire_after == 0 then + local dm = require "util.datamanager"; + setmetatable(pastes, { + __index = function (pastes, id) + if type(id) == "string" then + return dm.load(id, module.host, "pastebin"); + end + end; + __newindex = function (pastes, id, data) + if type(id) == "string" then + dm.store(id, module.host, "pastebin", data); + end + end; + }); + else + setmetatable(pastes, nil); + end +end + function module.save() return { pastes = pastes }; end