mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
66845def85
addresses #2852 - Moves storage modules to use prototypes and to create prototypes that inherit from the base storage ctor. - Makes storage/base conform to an all Promise interface.
26 lines
No EOL
741 B
JavaScript
26 lines
No EOL
741 B
JavaScript
var errors = require('../errors'),
|
|
storage = {};
|
|
|
|
function getStorage(storageChoice) {
|
|
// TODO: this is where the check for storage apps should go
|
|
// Local file system is the default. Fow now that is all we support.
|
|
storageChoice = 'localfilesystem';
|
|
|
|
if (storage[storageChoice]) {
|
|
return storage[storageChoice];
|
|
}
|
|
|
|
try {
|
|
// TODO: determine if storage has all the necessary methods.
|
|
storage[storageChoice] = require('./' + storageChoice);
|
|
} catch (e) {
|
|
errors.logError(e);
|
|
}
|
|
|
|
// Instantiate and cache the storage module instance.
|
|
storage[storageChoice] = new storage[storageChoice]();
|
|
|
|
return storage[storageChoice];
|
|
}
|
|
|
|
module.exports.getStorage = getStorage; |