# HG changeset patch # User Kim Alvefur # Date 1427301953 -3600 # Node ID 25441bd8b3441fac5c9a4b4498572772428b5e59 # Parent 1d2dc6c74581ae74c97d49617df3a6cccbf7f873 mod_storage_gdbm: Add purge action diff -r 1d2dc6c74581 -r 25441bd8b344 mod_storage_gdbm/mod_storage_gdbm.lua --- a/mod_storage_gdbm/mod_storage_gdbm.lua Wed Mar 25 17:45:17 2015 +0100 +++ b/mod_storage_gdbm/mod_storage_gdbm.lua Wed Mar 25 17:45:53 2015 +0100 @@ -151,6 +151,18 @@ return setmetatable({ _db = db; _path = db_path; store = store, typ = type }, driver_mt); end +function purge(_, user) + for dir in lfs.dir(base_path) do + local name, ext = dir:match("^(.-)%.a?db$"); + if ext == ".db" then + open(_, name, "keyval"):set(user, nil); + elseif ext == ".adb" then + open(_, name, "archive"):delete(user); + end + end + return true; +end + function module.unload() for path, db in pairs(cache) do gdbm.sync(db);