diff --git a/src/fs.js b/src/fs.js index 440a3ab..8506327 100644 --- a/src/fs.js +++ b/src/fs.js @@ -227,7 +227,7 @@ define(function(require) { * set extended attribute (refactor) */ - function set_extended_attribute (context, path, name, value, flag, callback) { + function set_extended_attribute (context, path_or_fd, name, value, flag, callback) { function set_xattr (error, node) { var xattr = (node ? node.xattrs[name] : null); @@ -246,11 +246,11 @@ define(function(require) { } } - if (typeof path == 'string') { - find_node(context, path, set_xattr); + if (typeof path_or_fd == 'string') { + find_node(context, path_or_fd, set_xattr); } - else if (typeof path.id == 'string') { - context.get(path.id, set_xattr); + else if (typeof path_or_fd == 'object' && typeof path_or_fd.id == 'string') { + context.get(path_or_fd.id, set_xattr); } else { callback(new EInvalid('path or file descriptor of wrong type')); diff --git a/tests/spec/fs.xattr.spec.js b/tests/spec/fs.xattr.spec.js index 1dfc793..e9e3db3 100644 --- a/tests/spec/fs.xattr.spec.js +++ b/tests/spec/fs.xattr.spec.js @@ -15,18 +15,11 @@ define(["IDBFS"], function(IDBFS) { }); it('should be a function', function () { - // that = this; - - // that.fs.writeFile('/testfile/this/is/a/dir/tmp', function (error) { - // if (error) throw error; - - // that.fs.setxattr('/testfile/this/is/a/dir/tmp', 'test', 'value', function (error) { - - // }); - // }); - expect(typeof this.fs.setxattr).toEqual('function'); expect(typeof this.fs.getxattr).toEqual('function'); + expect(typeof this.fs.removexattr).toEqual('function'); + expect(typeof this.fs.fsetxattr).toEqual('function'); + expect(typeof this.fs.fgetxattr).toEqual('function'); }); it('should error when setting with a name that is not a string', function () {