Merge branch 'develop' into issue#122
This commit is contained in:
commit
23706acffd
|
@ -1348,7 +1348,7 @@ sh.tempDir(function(err, tmp) {
|
|||
});
|
||||
```
|
||||
|
||||
#### sh.mkdirp(callback)<a name="mkdirp"></a>
|
||||
#### sh.mkdirp(path, callback)<a name="mkdirp"></a>
|
||||
|
||||
Recursively creates the directory at the provided path. If the
|
||||
directory already exists, no error is returned. All parents must
|
||||
|
|
|
@ -9,6 +9,7 @@ define(function(require) {
|
|||
|
||||
var IDB_RW = require('src/constants').IDB_RW;
|
||||
var IDB_RO = require('src/constants').IDB_RO;
|
||||
var Errors = require('src/errors');
|
||||
|
||||
function IndexedDBContext(db, mode) {
|
||||
var transaction = db.transaction(FILE_STORE_NAME, mode);
|
||||
|
@ -112,7 +113,7 @@ define(function(require) {
|
|||
callback(null, firstAccess);
|
||||
};
|
||||
openRequest.onerror = function onerror(error) {
|
||||
callback(error);
|
||||
callback(new Errors.EINVAL('IndexedDB cannot be accessed. If private browsing is enabled, disable it.'));
|
||||
};
|
||||
};
|
||||
IndexedDB.prototype.getReadOnlyContext = function() {
|
||||
|
|
|
@ -5,6 +5,7 @@ define(function(require) {
|
|||
var WSQL_SIZE = require('src/constants').WSQL_SIZE;
|
||||
var WSQL_DESC = require('src/constants').WSQL_DESC;
|
||||
var u8toArray = require('src/shared').u8toArray;
|
||||
var Errors = require('src/errors');
|
||||
|
||||
function WebSQLContext(db, isReadOnly) {
|
||||
var that = this;
|
||||
|
@ -116,6 +117,9 @@ define(function(require) {
|
|||
}
|
||||
|
||||
function onError(transaction, error) {
|
||||
if (error.code === 5) {
|
||||
callback(new Errors.EINVAL('WebSQL cannot be accessed. If private browsing is enabled, disable it.'));
|
||||
}
|
||||
callback(error);
|
||||
}
|
||||
function onSuccess(transaction, result) {
|
||||
|
|
|
@ -499,19 +499,32 @@ define(function(require) {
|
|||
callback = callback || function(){};
|
||||
|
||||
if(!path) {
|
||||
callback(new Errors.EINVAL('missing path argument'));
|
||||
callback(new Errors.EINVAL("Missing path argument"));
|
||||
return;
|
||||
}
|
||||
else if (path === '/'){
|
||||
else if (path === '/') {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
function _mkdirp(path, callback){
|
||||
function _mkdirp(path, callback) {
|
||||
fs.stat(path, function (err, stat) {
|
||||
//doesn't exist
|
||||
if (err && err.code === 'ENOENT') {
|
||||
if(stat) {
|
||||
if(stat.isDirectory()) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
else if (stat.isFile()) {
|
||||
callback(new Errors.ENOTDIR());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (err && err.code !== 'ENOENT') {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
var parent = Path.dirname(path);
|
||||
if(parent === '/'){ //parent is root
|
||||
if(parent === '/') {
|
||||
fs.mkdir(path, function (err) {
|
||||
if (err && err.code != 'EEXIST') {
|
||||
callback(err);
|
||||
|
@ -521,10 +534,10 @@ define(function(require) {
|
|||
return;
|
||||
});
|
||||
}
|
||||
else { //parent is not root, make parent first
|
||||
else {
|
||||
_mkdirp(parent, function (err) {
|
||||
if (err) return callback(err);
|
||||
fs.mkdir(path, function (err) { //then make dir
|
||||
fs.mkdir(path, function (err) {
|
||||
if (err && err.code != 'EEXIST') {
|
||||
callback(err);
|
||||
return;
|
||||
|
@ -535,21 +548,7 @@ define(function(require) {
|
|||
});
|
||||
}
|
||||
}
|
||||
//other error
|
||||
else if (err){
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
//already exists
|
||||
else if (stat.type === 'DIRECTORY') {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
//not a directory
|
||||
else if (stat.type === 'FILE') {
|
||||
callback(new Errors.ENOTDIR());
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue