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) {
|
function createClient(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var provider = options.provider || 'filesystem';
|
var provider = options.provider || 'filesystem';
|
||||||
|
var handler;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Try to load the provider from providers folder
|
// Try to load the provider from providers folder
|
||||||
provider = require('./providers/' + provider);
|
handler = require('./providers/' + provider);
|
||||||
return provider.createClient(options);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Fall back to pkgcloud
|
// 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) {
|
function FileSystemProvider(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.root = options.root;
|
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);
|
var stat = fs.statSync(this.root);
|
||||||
if (!stat.isDirectory()) {
|
if (!stat.isDirectory()) {
|
||||||
throw new Error('Invalid directory: ' + this.root);
|
throw new Error('Invalid directory: ' + this.root);
|
||||||
|
|
Loading…
Reference in New Issue