diff --git a/src/filesystem/implementation.js b/src/filesystem/implementation.js index e9a6a9b..dbb371e 100644 --- a/src/filesystem/implementation.js +++ b/src/filesystem/implementation.js @@ -279,12 +279,52 @@ function find_node(context, path, callback) { } /** - * find_lnode + * find_symlink_node */ // in: file or directory path -// out: node structure, or error -function find_symbolic_node(context, path, callback) { - lstat_file(context, path, callback); +// out: symlink node structure, or error +function find_symlink_node(context, path, callback) { + path = normalize(path); + var name = basename(path); + var parentPath = dirname(path); + + var directoryNode; + var directoryData; + + if(ROOT_DIRECTORY_NAME === name) { + find_node(context, path, callback); + } else { + find_node(context, parentPath, read_directory_data); + } + + function read_directory_data(error, result) { + if(error) { + callback(error); + } else { + directoryNode = result; + context.getObject(directoryNode.data, check_if_file_exists); + } + } + + function create_node(error, data) { + if(error) { + return callback(error); + } + Node.create(data, callback); + } + + function check_if_file_exists(error, result) { + if(error) { + callback(error); + } else { + directoryData = result; + if(!directoryData.hasOwnProperty(name)) { + callback(new Errors.ENOENT('a component of the path does not name an existing file', path)); + } else { + context.getObject(directoryData[name].id, create_node); + } + } + } } /** @@ -2078,7 +2118,7 @@ function lchown_file(context, path, uid, gid, callback) { update_node_times(context, path, node, { mtime: Date.now() }, callback); } } - find_symbolic_node(context, path, update_owner); + find_symlink_node(context, path, update_owner); } function getxattr(context, path, name, callback) { diff --git a/src/filesystem/interface.js b/src/filesystem/interface.js index d6e9390..93e491b 100644 --- a/src/filesystem/interface.js +++ b/src/filesystem/interface.js @@ -341,7 +341,6 @@ function FileSystem(options, callback) { { name: 'futimes' }, { name: 'getxattr', promises: true, absPathArgs: [0] }, { name: 'lchown' }, - // lchmod - https://github.com/filerjs/filer/issues/619 { name: 'link', promises: true, absPathArgs: [0, 1] }, { name: 'lseek' }, { name: 'lstat', promises: true },