Fix bug making provider fallthrough to pkgcloud when a directory doesn't exist, making a very unintuitive error.
This commit is contained in:
parent
6cbf564132
commit
50ce215142
|
@ -6,15 +6,17 @@
|
|||
function createClient(options) {
|
||||
options = options || {};
|
||||
var provider = options.provider || 'filesystem';
|
||||
var handler;
|
||||
|
||||
try {
|
||||
// Try to load the provider from providers folder
|
||||
provider = require('./providers/' + provider);
|
||||
return provider.createClient(options);
|
||||
handler = require('./providers/' + provider);
|
||||
} catch (err) {
|
||||
// Fall back to pkgcloud
|
||||
return require('pkgcloud').storage.createClient(options);
|
||||
handler = require('pkgcloud').storage;
|
||||
}
|
||||
|
||||
return handler.createClient(options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,10 @@ module.exports.createClient = function (options) {
|
|||
function FileSystemProvider(options) {
|
||||
options = options || {};
|
||||
this.root = options.root;
|
||||
var exists = fs.existsSync(this.root);
|
||||
if (!exists) {
|
||||
throw new Error('Path does not exist: ' + this.root);
|
||||
}
|
||||
var stat = fs.statSync(this.root);
|
||||
if (!stat.isDirectory()) {
|
||||
throw new Error('Invalid directory: ' + this.root);
|
||||
|
|
Loading…
Reference in New Issue