v0.0.27
This commit is contained in:
parent
e79a6302ce
commit
3134c0be46
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "filer",
|
"name": "filer",
|
||||||
"version": "0.0.26",
|
"version": "0.0.27",
|
||||||
"main": "dist/filer.js",
|
"main": "dist/filer.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mocha": "1.17.1",
|
"mocha": "1.17.1",
|
||||||
|
|
|
@ -13812,10 +13812,13 @@ function validate_file_options(options, enc, fileMode){
|
||||||
|
|
||||||
function pathCheck(path, callback) {
|
function pathCheck(path, callback) {
|
||||||
var err;
|
var err;
|
||||||
if(isNullPath(path)) {
|
|
||||||
|
if(!path) {
|
||||||
|
err = new Errors.EINVAL('Path must be a string', path);
|
||||||
|
} else if(isNullPath(path)) {
|
||||||
err = new Errors.EINVAL('Path must be a string without null bytes.', path);
|
err = new Errors.EINVAL('Path must be a string without null bytes.', path);
|
||||||
} else if(!isAbsolutePath(path)) {
|
} else if(!isAbsolutePath(path)) {
|
||||||
err = new Errors.EINAVL('Path must be absolute.', path);
|
err = new Errors.EINVAL('Path must be absolute.', path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err) {
|
if(err) {
|
||||||
|
@ -14526,9 +14529,8 @@ function FileSystem(options, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open file system storage provider
|
// Open file system storage provider
|
||||||
provider.open(function(err, needsFormatting) {
|
provider.open(function(err) {
|
||||||
function complete(error) {
|
function complete(error) {
|
||||||
|
|
||||||
function wrappedContext(methodName) {
|
function wrappedContext(methodName) {
|
||||||
var context = provider[methodName]();
|
var context = provider[methodName]();
|
||||||
context.flags = flags;
|
context.flags = flags;
|
||||||
|
@ -14571,20 +14573,22 @@ function FileSystem(options, callback) {
|
||||||
return complete(err);
|
return complete(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we don't need or want formatting, we're done
|
|
||||||
if(!(forceFormatting || needsFormatting)) {
|
|
||||||
return complete(null);
|
|
||||||
}
|
|
||||||
// otherwise format the fs first
|
|
||||||
var context = provider.getReadWriteContext();
|
var context = provider.getReadWriteContext();
|
||||||
context.guid = wrappedGuidFn(context);
|
context.guid = wrappedGuidFn(context);
|
||||||
context.clear(function(err) {
|
|
||||||
if(err) {
|
// Mount the filesystem, formatting if necessary
|
||||||
complete(err);
|
if(forceFormatting) {
|
||||||
return;
|
// Wipe the storage provider, then write root block
|
||||||
}
|
context.clear(function(err) {
|
||||||
|
if(err) {
|
||||||
|
return complete(err);
|
||||||
|
}
|
||||||
|
impl.ensureRootDirectory(context, complete);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Use existing (or create new) root and mount
|
||||||
impl.ensureRootDirectory(context, complete);
|
impl.ensureRootDirectory(context, complete);
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15184,15 +15188,10 @@ IndexedDB.prototype.open = function(callback) {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
// Bail if we already have a db open
|
// Bail if we already have a db open
|
||||||
if( that.db ) {
|
if(that.db) {
|
||||||
callback(null, false);
|
return callback();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of whether we're accessing this db for the first time
|
|
||||||
// and therefore needs to get formatted.
|
|
||||||
var firstAccess = false;
|
|
||||||
|
|
||||||
// NOTE: we're not using versioned databases.
|
// NOTE: we're not using versioned databases.
|
||||||
var openRequest = indexedDB.open(that.name);
|
var openRequest = indexedDB.open(that.name);
|
||||||
|
|
||||||
|
@ -15204,13 +15203,11 @@ IndexedDB.prototype.open = function(callback) {
|
||||||
db.deleteObjectStore(FILE_STORE_NAME);
|
db.deleteObjectStore(FILE_STORE_NAME);
|
||||||
}
|
}
|
||||||
db.createObjectStore(FILE_STORE_NAME);
|
db.createObjectStore(FILE_STORE_NAME);
|
||||||
|
|
||||||
firstAccess = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
openRequest.onsuccess = function onsuccess(event) {
|
openRequest.onsuccess = function onsuccess(event) {
|
||||||
that.db = event.target.result;
|
that.db = event.target.result;
|
||||||
callback(null, firstAccess);
|
callback();
|
||||||
};
|
};
|
||||||
openRequest.onerror = function onerror(error) {
|
openRequest.onerror = function onerror(error) {
|
||||||
callback(new Errors.EINVAL('IndexedDB cannot be accessed. If private browsing is enabled, disable it.'));
|
callback(new Errors.EINVAL('IndexedDB cannot be accessed. If private browsing is enabled, disable it.'));
|
||||||
|
@ -15241,14 +15238,10 @@ var asyncCallback = _dereq_('../../lib/async.js').setImmediate;
|
||||||
var createDB = (function() {
|
var createDB = (function() {
|
||||||
var pool = {};
|
var pool = {};
|
||||||
return function getOrCreate(name) {
|
return function getOrCreate(name) {
|
||||||
var firstAccess = !pool.hasOwnProperty(name);
|
if(!pool.hasOwnProperty(name)) {
|
||||||
if(firstAccess) {
|
|
||||||
pool[name] = {};
|
pool[name] = {};
|
||||||
}
|
}
|
||||||
return {
|
return pool[name];
|
||||||
firstAccess: firstAccess,
|
|
||||||
db: pool[name]
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
@ -15313,11 +15306,8 @@ Memory.isSupported = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Memory.prototype.open = function(callback) {
|
Memory.prototype.open = function(callback) {
|
||||||
var result = createDB(this.name);
|
this.db = createDB(this.name);
|
||||||
this.db = result.db;
|
asyncCallback(callback);
|
||||||
asyncCallback(function() {
|
|
||||||
callback(null, result.firstAccess);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
Memory.prototype.getReadOnlyContext = function() {
|
Memory.prototype.getReadOnlyContext = function() {
|
||||||
return new MemoryContext(this.db, true);
|
return new MemoryContext(this.db, true);
|
||||||
|
@ -15462,8 +15452,7 @@ WebSQL.prototype.open = function(callback) {
|
||||||
|
|
||||||
// Bail if we already have a db open
|
// Bail if we already have a db open
|
||||||
if(that.db) {
|
if(that.db) {
|
||||||
callback(null, false);
|
return callback();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var db = global.openDatabase(that.name, WSQL_VERSION, WSQL_DESC, WSQL_SIZE);
|
var db = global.openDatabase(that.name, WSQL_VERSION, WSQL_DESC, WSQL_SIZE);
|
||||||
|
@ -15480,18 +15469,7 @@ WebSQL.prototype.open = function(callback) {
|
||||||
}
|
}
|
||||||
function onSuccess(transaction, result) {
|
function onSuccess(transaction, result) {
|
||||||
that.db = db;
|
that.db = db;
|
||||||
|
callback();
|
||||||
function gotCount(transaction, result) {
|
|
||||||
var firstAccess = result.rows.item(0).count === 0;
|
|
||||||
callback(null, firstAccess);
|
|
||||||
}
|
|
||||||
function onError(transaction, error) {
|
|
||||||
callback(error);
|
|
||||||
}
|
|
||||||
// Keep track of whether we're accessing this db for the first time
|
|
||||||
// and therefore needs to get formatted.
|
|
||||||
transaction.executeSql("SELECT COUNT(id) AS count FROM " + FILE_STORE_NAME + ";",
|
|
||||||
[], gotCount, onError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the table and index we'll need to store the fs data.
|
// Create the table and index we'll need to store the fs data.
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -11,7 +11,7 @@
|
||||||
"idb",
|
"idb",
|
||||||
"websql"
|
"websql"
|
||||||
],
|
],
|
||||||
"version": "0.0.26",
|
"version": "0.0.27",
|
||||||
"author": "Alan K <ack@modeswitch.org> (http://blog.modeswitch.org)",
|
"author": "Alan K <ack@modeswitch.org> (http://blog.modeswitch.org)",
|
||||||
"homepage": "http://js-platform.github.io/filer",
|
"homepage": "http://js-platform.github.io/filer",
|
||||||
"bugs": "https://github.com/js-platform/filer/issues",
|
"bugs": "https://github.com/js-platform/filer/issues",
|
||||||
|
|
Loading…
Reference in New Issue