# HG changeset patch # User Kim Alvefur # Date 1699214783 -3600 # Node ID 78f766372e2c498efce3d2b8a801d3651bf36ebe # Parent ea6c18ec0669a12213bfe839fbb73a73ef938a8c mod_storage_appendmap: Include timestamps when appending data Meant to give some sense of when each piece of data was added, to aid in debugging changes or manual rollbacks. diff -r ea6c18ec0669 -r 78f766372e2c mod_storage_appendmap/mod_storage_appendmap.lua --- a/mod_storage_appendmap/mod_storage_appendmap.lua Sun Nov 05 21:03:30 2023 +0100 +++ b/mod_storage_appendmap/mod_storage_appendmap.lua Sun Nov 05 21:06:23 2023 +0100 @@ -1,11 +1,13 @@ local dump = require "util.serialization".serialize; local load = require "util.envload".envloadfile; +local datetime = require "util.datetime".datetime; local dm = require "core.storagemanager".olddm; local REMOVE = {}; -- Special value for removing keys local driver = {}; +local timestamps = module:get_option_boolean("appendmap_timestamps", true); local keywords = { ["do"] = true; ["and"] = true; ["else"] = true; ["break"] = true; @@ -82,6 +84,9 @@ function map:set_keys(user, keyvalues) local data = serialize_map(keyvalues); + if timestamps then + data = "-- " .. datetime() .. "\n" .. data; + end return dm.append_raw(user, module.host, self.store, "map", data); end @@ -94,6 +99,9 @@ return os.remove(filename); end local data = serialize_pair(key, value); + if timestamps then + data = "-- " .. datetime() .. "\n" .. data; + end return dm.append_raw(user, module.host, self.store, "map", data); end @@ -110,6 +118,9 @@ function keyval:set(user, keyvalues) local data = serialize_map(keyvalues); + if timestamps then + data = "-- " .. datetime() .. "\n" .. data; + end return dm.store_raw(dm.getpath(user, module.host, self.store, "map"), data); end