Skip to content

Commit

Permalink
Add: ignoreFdError opts
Browse files Browse the repository at this point in the history
  • Loading branch information
Bacra committed Sep 8, 2015
1 parent c447386 commit 762771e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion abq.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exports.defaults = {
fd : null,
flag : 'a',
mode : parseInt('0644', 8),
ignoreFdError : true,
// 超过写的队列就准备写入文件
writeLength : 100,
// fd还没创建 日志过满的时候 0 为不限制
Expand Down Expand Up @@ -116,7 +117,11 @@ extend(ADQ.prototype, {
}

this._genfd.generate(file, self.opts.flag, this.opts.mode, function(err, fd) {
if (!err && noAutoBind !== true) self.bindfd(fd);
// 可以忽略mode 错误 只要有fd,就可以去绑定
if (fd && (!err || self.opts.ignoreFdError) && noAutoBind !== true) {
self.bindfd(fd);
self._genfd.fd = fd;
}
self.emit('open', err, fd, noAutoBind, file);
});
},
Expand Down Expand Up @@ -262,6 +267,8 @@ GenFd.prototype = {
], function(err) {
if (!err) {
self.fd = thisFd;
} else {
debug('generate fd err:%o', err);
}
self._fding = false;
callback(err, thisFd);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "abq",
"version": "0.1.8",
"version": "0.1.9",
"description": "Append data to a file in query.",
"main": "abq.js",
"repository": {
Expand Down

0 comments on commit 762771e

Please sign in to comment.