Software /
code /
prosody
Comparison
core/storagemanager.lua @ 5043:2856e1cfbe95
Merge with Zash
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 28 Jul 2012 20:59:03 +0100 |
parent | 5041:be204204cc5f |
child | 5110:72a7427368f8 |
comparison
equal
deleted
inserted
replaced
5031:28d56268a72d | 5043:2856e1cfbe95 |
---|---|
56 log("error", "Failed to load storage driver plugin %s on %s: %s", driver_name, host, err); | 56 log("error", "Failed to load storage driver plugin %s on %s: %s", driver_name, host, err); |
57 end | 57 end |
58 return stores_available:get(host, driver_name); | 58 return stores_available:get(host, driver_name); |
59 end | 59 end |
60 | 60 |
61 function open(host, store, typ) | 61 function get_driver(host, store) |
62 local storage = config.get(host, "core", "storage"); | 62 local storage = config.get(host, "core", "storage"); |
63 local driver_name; | 63 local driver_name; |
64 local option_type = type(storage); | 64 local option_type = type(storage); |
65 if option_type == "string" then | 65 if option_type == "string" then |
66 driver_name = storage; | 66 driver_name = storage; |
75 if not driver then | 75 if not driver then |
76 log("warn", "Falling back to null driver for %s storage on %s", store, host); | 76 log("warn", "Falling back to null driver for %s storage on %s", store, host); |
77 driver_name = "null"; | 77 driver_name = "null"; |
78 driver = null_storage_driver; | 78 driver = null_storage_driver; |
79 end | 79 end |
80 return driver, driver_name; | |
81 end | |
80 | 82 |
83 function open(host, store, typ) | |
84 local driver, driver_name = get_driver(host, store); | |
81 local ret, err = driver:open(store, typ); | 85 local ret, err = driver:open(store, typ); |
82 if not ret then | 86 if not ret then |
83 if err == "unsupported-store" then | 87 if err == "unsupported-store" then |
84 log("debug", "Storage driver %s does not support store %s (%s), falling back to null driver", | 88 log("debug", "Storage driver %s does not support store %s (%s), falling back to null driver", |
85 driver_name, store, typ); | 89 driver_name, store, typ); |
94 return open(host, datastore):get(username); | 98 return open(host, datastore):get(username); |
95 end | 99 end |
96 function datamanager.store(username, host, datastore, data) | 100 function datamanager.store(username, host, datastore, data) |
97 return open(host, datastore):set(username, data); | 101 return open(host, datastore):set(username, data); |
98 end | 102 end |
103 function datamanager.list_stores(username, host) | |
104 return get_driver(host):list_stores(username, host); | |
105 end | |
106 function datamanager.purge(username, host) | |
107 return get_driver(host):purge(username, host); | |
108 end | |
99 | 109 |
100 return _M; | 110 return _M; |