Software /
code /
prosody
Comparison
core/storagemanager.lua @ 6949:1c2c3d913172
storagemanager: Split config retrieval into its own function
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 03 Dec 2015 14:47:47 +0000 |
parent | 6809:dd6b21862e3b |
child | 6951:99de8f30d99e |
comparison
equal
deleted
inserted
replaced
6948:e6968e47826d | 6949:1c2c3d913172 |
---|---|
55 log("error", "Failed to load storage driver plugin %s on %s: %s", driver_name, host, err); | 55 log("error", "Failed to load storage driver plugin %s on %s: %s", driver_name, host, err); |
56 end | 56 end |
57 return stores_available:get(host, driver_name); | 57 return stores_available:get(host, driver_name); |
58 end | 58 end |
59 | 59 |
60 local function get_storage_config(host) | |
61 return config.get(host, "storage"); | |
62 end | |
63 | |
60 local function get_driver(host, store) | 64 local function get_driver(host, store) |
61 local storage = config.get(host, "storage"); | 65 local storage = get_storage_config(host); |
62 local driver_name; | 66 local driver_name; |
63 local option_type = type(storage); | 67 local option_type = type(storage); |
64 if option_type == "string" then | 68 if option_type == "string" then |
65 driver_name = storage; | 69 driver_name = storage; |
66 elseif option_type == "table" then | 70 elseif option_type == "table" then |
92 end | 96 end |
93 return ret, err; | 97 return ret, err; |
94 end | 98 end |
95 | 99 |
96 local function purge(user, host) | 100 local function purge(user, host) |
97 local storage = config.get(host, "storage"); | 101 local storage = get_storage_config(host); |
98 if type(storage) == "table" then | 102 if type(storage) == "table" then |
99 -- multiple storage backends in use that we need to purge | 103 -- multiple storage backends in use that we need to purge |
100 local purged = {}; | 104 local purged = {}; |
101 for store, driver_name in pairs(storage) do | 105 for store, driver_name in pairs(storage) do |
102 if not purged[driver_name] then | 106 if not purged[driver_name] then |