Software /
code /
prosody
Comparison
plugins/mod_storage_sql.lua @ 9890:b5ac12f97f34
mod_storage_sql: Fix to use currently queried store
Was using the previously queried store due to this being cached in an
upvalue.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 22 Mar 2019 02:10:46 +0100 |
parent | 9889:e3ad2c845431 |
child | 9891:147b28d001a0 |
comparison
equal
deleted
inserted
replaced
9889:e3ad2c845431 | 9890:b5ac12f97f34 |
---|---|
236 quota = archive_item_limit; | 236 quota = archive_item_limit; |
237 truncate = true; | 237 truncate = true; |
238 }; | 238 }; |
239 archive_store.__index = archive_store | 239 archive_store.__index = archive_store |
240 function archive_store:append(username, key, value, when, with) | 240 function archive_store:append(username, key, value, when, with) |
241 local cache_key = jid_join(username, host, self.store); | 241 local user,store = username,self.store; |
242 local cache_key = jid_join(username, host, store); | |
242 local item_count = archive_item_count_cache:get(cache_key); | 243 local item_count = archive_item_count_cache:get(cache_key); |
243 if not item_count then | 244 if not item_count then |
244 local ok, ret = engine:transaction(function() | 245 local ok, ret = engine:transaction(function() |
245 local count_sql = [[ | 246 local count_sql = [[ |
246 SELECT COUNT(*) FROM "prosodyarchive" | 247 SELECT COUNT(*) FROM "prosodyarchive" |
263 module:log("debug", "%s has %d items out of %d limit", username, item_count, archive_item_limit); | 264 module:log("debug", "%s has %d items out of %d limit", username, item_count, archive_item_limit); |
264 if item_count >= archive_item_limit then | 265 if item_count >= archive_item_limit then |
265 return nil, "quota-limit"; | 266 return nil, "quota-limit"; |
266 end | 267 end |
267 | 268 |
268 local user,store = username,self.store; | |
269 when = when or os.time(); | 269 when = when or os.time(); |
270 with = with or ""; | 270 with = with or ""; |
271 local ok, ret = engine:transaction(function() | 271 local ok, ret = engine:transaction(function() |
272 local delete_sql = [[ | 272 local delete_sql = [[ |
273 DELETE FROM "prosodyarchive" | 273 DELETE FROM "prosodyarchive" |