# HG changeset patch # User Kim Alvefur # Date 1427301843 -3600 # Node ID 050d101af20707a298ab55ad39c39cbee0fe99af # Parent 98427ed3d53fa07c11b85886ff61ac3fc099967b mod_storage_gdbm: Prefix archive item keys with username to prevent collisions diff -r 98427ed3d53f -r 050d101af207 mod_storage_gdbm/mod_storage_gdbm.lua --- a/mod_storage_gdbm/mod_storage_gdbm.lua Wed Mar 25 17:41:13 2015 +0100 +++ b/mod_storage_gdbm/mod_storage_gdbm.lua Wed Mar 25 17:44:03 2015 +0100 @@ -78,7 +78,8 @@ end meta[i] = { key = key, when = when, with = with, type = type }; meta[key] = i; - local ok, err = self:set(key, value); + local prefix = (username or "@") .. "#"; + local ok, err = self:set(prefix..key, value); if not ok then return nil, err; end ok, err = self:set(username, meta); if not ok then return nil, err; end @@ -92,6 +93,7 @@ function archive:find(username, query) query = query or empty_query; local meta = self:get(username) or empty; + local prefix = (username or "@") .. "#"; local r = query.reverse; local d = t(r, -1, 1); local s = meta[t(r, query.before, query.after)]; @@ -112,7 +114,7 @@ and (not query.start or item.when >= query.start) and (not query["end"] or item.when <= query["end"]) then s = i + d; c = c + 1; - value = self:get(item.key); + value = self:get(prefix..item.key); return item.key, (deserialize[item.type] or id)(value), item.when, item.with; end end