Software /
code /
prosody-modules
Changeset
516:3d3687fef751
mod_pastebin: Fix issue with metatable not being set when a reload changes expires_after to 0
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 21 Dec 2011 10:25:17 +0000 |
parents | 515:e98fe28c50b0 |
children | 517:f866325305ed |
files | mod_pastebin/mod_pastebin.lua |
diffstat | 1 files changed, 20 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- 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