Comparison

core/storagemanager.lua @ 5129:e8253c931166

storagemanager: Add purge() for purging user data from all backends in use
author Kim Alvefur <zash@zash.se>
date Sun, 16 Sep 2012 02:18:07 +0200
parent 5111:7e577727fb9f
child 5130:051d352ed03c
comparison
equal deleted inserted replaced
5128:834ab74585ec 5129:e8253c931166
92 end 92 end
93 end 93 end
94 return ret, err; 94 return ret, err;
95 end 95 end
96 96
97 function purge(user, host)
98 local storage = config.get(host, "core", "storage");
99 local driver_name;
100 if type(storage) == "table" then
101 -- multiple storage backends in use that we need to purge
102 local purged = {};
103 for store, driver in pairs(storage) do
104 if not purged[driver] then
105 purged[driver] = get_driver(host, store):purge(user);
106 end
107 end
108 end
109 get_driver(host):purge(user); -- and the default driver
110
111 olddm.purge(user, host); -- COMPAT list stores, like offline messages end up in the old datamanager
112
113 return true;
114 end
115
97 function datamanager.load(username, host, datastore) 116 function datamanager.load(username, host, datastore)
98 return open(host, datastore):get(username); 117 return open(host, datastore):get(username);
99 end 118 end
100 function datamanager.store(username, host, datastore, data) 119 function datamanager.store(username, host, datastore, data)
101 return open(host, datastore):set(username, data); 120 return open(host, datastore):set(username, data);
102 end 121 end
103 function datamanager.list_stores(username, host) 122 function datamanager.list_stores(username, host)
104 return get_driver(host):list_stores(username); 123 return get_driver(host):list_stores(username);
105 end 124 end
106 function datamanager.purge(username, host) 125 function datamanager.purge(username, host)
107 return get_driver(host):purge(username); 126 return purge(username);
108 end 127 end
109 128
110 return _M; 129 return _M;