Software /
code /
prosody
Diff
core/storagemanager.lua @ 5133:1443d1c37c6c
Merge 0.9->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 19 Sep 2012 12:14:08 +0100 |
parent | 5121:b5a5643f8572 |
parent | 5131:0cd962661fa2 |
child | 5136:77ea38607a89 |
line wrap: on
line diff
--- a/core/storagemanager.lua Thu Sep 13 18:49:25 2012 +0100 +++ b/core/storagemanager.lua Wed Sep 19 12:14:08 2012 +0100 @@ -59,7 +59,7 @@ end function get_driver(host, store) - local storage = config.get(host, "core", "storage"); + local storage = config.get(host, "storage"); local driver_name; local option_type = type(storage); if option_type == "string" then @@ -68,7 +68,7 @@ driver_name = storage[store]; end if not driver_name then - driver_name = config.get(host, "core", "default_storage") or "internal"; + driver_name = config.get(host, "default_storage") or "internal"; end local driver = load_driver(host, driver_name); @@ -94,17 +94,36 @@ return ret, err; end +function purge(user, host) + local storage = config.get(host, "storage"); + local driver_name; + if type(storage) == "table" then + -- multiple storage backends in use that we need to purge + local purged = {}; + for store, driver in pairs(storage) do + if not purged[driver] then + purged[driver] = get_driver(host, store):purge(user); + end + end + end + get_driver(host):purge(user); -- and the default driver + + olddm.purge(user, host); -- COMPAT list stores, like offline messages end up in the old datamanager + + return true; +end + function datamanager.load(username, host, datastore) return open(host, datastore):get(username); end function datamanager.store(username, host, datastore, data) return open(host, datastore):set(username, data); end -function datamanager.list_stores(username, host) - return get_driver(host):list_stores(username); +function datamanager.stores(username, host, typ) + return get_driver(host):stores(username, typ); end function datamanager.purge(username, host) - return get_driver(host):purge(username); + return purge(username); end return _M;