Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add error argument to callback for writing a message

  • Loading branch information...
commit ecb2622a50f3706f0862175982e123888ce4421d 1 parent c34dbec
@aredridel authored
Showing with 14 additions and 12 deletions.
  1. +2 −0  doc/api.markdown
  2. +12 −12 lib/mailbox.js
View
2  doc/api.markdown
@@ -31,4 +31,6 @@ formats, or is malicious in some way, or something weird happens.
When there is a callback, the retry is handled automatically.
+The callback gets two arguments, `(err, writableStream)`
+
FIXME: when the file is closed, move it into `new/`
View
24 lib/mailbox.js
@@ -15,18 +15,18 @@ Maildir.prototype.appendMessage = function(callback) {
, mode: 0600}
)
var self = this
- s.on('error', function(err) {
- console.log(err)
- if(err.message.match(/EEXIST/)) {
- self.appendMessage(callback)
- } else {
- s.destroy()
- }
- })
- s.on('open', function(fd) {
- if(callback) callback(s)
- })
- s.filename = messageName
+ if(callback) {
+ s.on('error', function(err) {
+ if(err.message.match(/EEXIST/)) {
+ self.appendMessage(callback)
+ } else {
+ callback(err, s)
+ }
+ })
+ s.on('open', function(fd) {
+ callback(null, s)
+ })
+ }
return s
}
Please sign in to comment.
Something went wrong with that request. Please try again.