# HG changeset patch # User Matthew Wild # Date 1294322199 0 # Node ID 00ce990713685d91c4e80a079fce712d460f2261 # Parent c082ded3b5f1fa1c141441c84e187cc6da4e8170 storagemanager: Add new "null" provider to get used when loading a driver or opening a store fails, instead of falling back to the default driver diff -r c082ded3b5f1 -r 00ce99071368 core/storagemanager.lua --- a/core/storagemanager.lua Thu Jan 06 13:54:37 2011 +0000 +++ b/core/storagemanager.lua Thu Jan 06 13:56:39 2011 +0000 @@ -15,6 +15,19 @@ module("storagemanager") +local null_storage_method = function () return false, "no data storage active"; end +local null_storage_driver = setmetatable( + { + name = "null", + open = function (self) return self; end + }, { + __index = function (self, method) + return null_storage_method; + end + } +); + +--TODO: Move default driver to mod_auth_internal local default_driver_mt = { name = "internal" }; default_driver_mt.__index = default_driver_mt; function default_driver_mt:open(store) @@ -73,10 +86,13 @@ if not driver then if driver_name or (type(storage) == "string" or type(storage) == "table" and storage[store]) then - log("warn", "Falling back to default driver for %s storage on %s", store, host); + log("warn", "Falling back to null driver for %s storage on %s", store, host); + driver_name = "null"; + driver = null_storage_driver; + else + driver_name = "internal"; + driver = load_driver(host, driver_name); end - driver_name = "internal"; - driver = load_driver(host, driver_name); end end @@ -85,7 +101,7 @@ if err == "unsupported-store" then log("debug", "Storage driver %s does not support store %s (%s), falling back to internal driver", driver_name, store, typ); - ret = setmetatable({ host = host, store = store }, default_driver_mt); -- default to default driver + ret = null_storage_driver; err = nil; end end