mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
5c640e95f5
closes #4600 - implemented as suggested in #4600 - loads a custom storage defined in config from the /content/storage directory
31 lines
784 B
JavaScript
31 lines
784 B
JavaScript
var errors = require('../errors'),
|
|
config = require('../config'),
|
|
storage = {};
|
|
|
|
function getStorage(storageChoice) {
|
|
var storagePath,
|
|
storageConfig;
|
|
|
|
storageChoice = config.storage.active;
|
|
storagePath = config.paths.storage;
|
|
storageConfig = config.storage[storageChoice];
|
|
|
|
if (storage[storageChoice]) {
|
|
return storage[storageChoice];
|
|
}
|
|
|
|
try {
|
|
// TODO: determine if storage has all the necessary methods.
|
|
storage[storageChoice] = require(storagePath);
|
|
} catch (e) {
|
|
errors.logError(e);
|
|
}
|
|
|
|
// Instantiate and cache the storage module instance.
|
|
storage[storageChoice] = new storage[storageChoice](storageConfig);
|
|
|
|
return storage[storageChoice];
|
|
}
|
|
|
|
module.exports.getStorage = getStorage;
|