fix remaining lint errors
This commit is contained in:
parent
c590f930e5
commit
638109f911
92
src/fs.js
92
src/fs.js
|
@ -121,46 +121,46 @@ define(function(require) {
|
||||||
var name = basename(path);
|
var name = basename(path);
|
||||||
var parentPath = dirname(path);
|
var parentPath = dirname(path);
|
||||||
|
|
||||||
if(ROOT_DIRECTORY_NAME == name) {
|
function check_root_directory_node(error, rootDirectoryNode) {
|
||||||
function check_root_directory_node(error, rootDirectoryNode) {
|
if(error) {
|
||||||
if(error) {
|
callback(error);
|
||||||
callback(error);
|
} else if(!rootDirectoryNode) {
|
||||||
} else if(!rootDirectoryNode) {
|
callback(new ENoEntry('path does not exist'));
|
||||||
|
} else {
|
||||||
|
callback(undefined, rootDirectoryNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// in: parent directory node
|
||||||
|
// out: parent directory data
|
||||||
|
function read_parent_directory_data(error, parentDirectoryNode) {
|
||||||
|
if(error) {
|
||||||
|
callback(error);
|
||||||
|
} else if(!(_(parentDirectoryNode).has('data') && parentDirectoryNode.type == MODE_DIRECTORY)) {
|
||||||
|
callback(new ENotDirectory('a component of the path prefix is not a directory'));
|
||||||
|
} else {
|
||||||
|
read_object(objectStore, parentDirectoryNode.data, get_node_id_from_parent_directory_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// in: parent directory data
|
||||||
|
// out: searched node id
|
||||||
|
function get_node_id_from_parent_directory_data(error, parentDirectoryData) {
|
||||||
|
if(error) {
|
||||||
|
callback(error);
|
||||||
|
} else {
|
||||||
|
if(!_(parentDirectoryData).has(name)) {
|
||||||
callback(new ENoEntry('path does not exist'));
|
callback(new ENoEntry('path does not exist'));
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, rootDirectoryNode);
|
var nodeId = parentDirectoryData[name].id;
|
||||||
|
read_object(objectStore, nodeId, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ROOT_DIRECTORY_NAME == name) {
|
||||||
read_object(objectStore, ROOT_NODE_ID, check_root_directory_node);
|
read_object(objectStore, ROOT_NODE_ID, check_root_directory_node);
|
||||||
} else {
|
} else {
|
||||||
// in: parent directory node
|
|
||||||
// out: parent directory data
|
|
||||||
function read_parent_directory_data(error, parentDirectoryNode) {
|
|
||||||
if(error) {
|
|
||||||
callback(error);
|
|
||||||
} else if(!_(parentDirectoryNode).has('data') || !parentDirectoryNode.type == MODE_DIRECTORY) {
|
|
||||||
callback(new ENotDirectory('a component of the path prefix is not a directory'));
|
|
||||||
} else {
|
|
||||||
read_object(objectStore, parentDirectoryNode.data, get_node_id_from_parent_directory_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// in: parent directory data
|
|
||||||
// out: searched node id
|
|
||||||
function get_node_id_from_parent_directory_data(error, parentDirectoryData) {
|
|
||||||
if(error) {
|
|
||||||
callback(error);
|
|
||||||
} else {
|
|
||||||
if(!_(parentDirectoryData).has(name)) {
|
|
||||||
callback(new ENoEntry('path does not exist'));
|
|
||||||
} else {
|
|
||||||
var nodeId = parentDirectoryData[name].id;
|
|
||||||
read_object(objectStore, nodeId, callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
find_node(objectStore, parentPath, read_parent_directory_data);
|
find_node(objectStore, parentPath, read_parent_directory_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1374,6 +1374,19 @@ define(function(require) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_descriptor_position(error, stats) {
|
||||||
|
if(error) {
|
||||||
|
deferred.reject(error);
|
||||||
|
} else {
|
||||||
|
if(stats.size + offset < 0) {
|
||||||
|
deferred.reject(new EInvalid('resulting file offset would be negative'));
|
||||||
|
} else {
|
||||||
|
ofd.position = stats.size + offset;
|
||||||
|
deferred.resolve(ofd.position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var ofd = that.openFiles[fd];
|
var ofd = that.openFiles[fd];
|
||||||
|
|
||||||
if(!ofd) {
|
if(!ofd) {
|
||||||
|
@ -1398,19 +1411,6 @@ define(function(require) {
|
||||||
var transaction = that.db.transaction([FILE_STORE_NAME], IDB_RW);
|
var transaction = that.db.transaction([FILE_STORE_NAME], IDB_RW);
|
||||||
var files = transaction.objectStore(FILE_STORE_NAME);
|
var files = transaction.objectStore(FILE_STORE_NAME);
|
||||||
|
|
||||||
function update_descriptor_position(error, stats) {
|
|
||||||
if(error) {
|
|
||||||
deferred.reject(error);
|
|
||||||
} else {
|
|
||||||
if(stats.size + offset < 0) {
|
|
||||||
deferred.reject(new EInvalid('resulting file offset would be negative'));
|
|
||||||
} else {
|
|
||||||
ofd.position = stats.size + offset;
|
|
||||||
deferred.resolve(ofd.position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fstat_file(files, ofd, update_descriptor_position);
|
fstat_file(files, ofd, update_descriptor_position);
|
||||||
} else {
|
} else {
|
||||||
deferred.reject(new EInvalid('whence argument is not a proper value'));
|
deferred.reject(new EInvalid('whence argument is not a proper value'));
|
||||||
|
|
Loading…
Reference in New Issue