code: function set_extended_attribute (context, path, node, name, value, flag, callback) {
    function update_time(error) {
      if(error) {
        callback(error);
      } else {
        update_node_times(context, path, node, { ctime: Date.now() }, callback);
      }
    }
  
    var xattrs = node.xattrs;
  
    if (flag === XATTR_CREATE && xattrs.hasOwnProperty(name)) {
      callback(new Errors.EEXIST('attribute already exists', path));
    }
    else if (flag === XATTR_REPLACE && !xattrs.hasOwnProperty(name)) {
      callback(new Errors.ENOATTR(null, path));
    }
    else {
      xattrs[name] = value;
      context.putObject(node.id, node, update_time);
    }
  }
docs: set extended attribute (refactor)