Skip to content

Commit

Permalink
Adding stats and fixing lazy reader case.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed May 11, 2012
1 parent db514b9 commit d9aff72
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.js
Expand Up @@ -43,6 +43,7 @@ function File (options) {
fs.stat(options.path, function (err, stats) {

var finish = function (err, stats) {
self.stat = stats
if (err && err.code === 'ENOENT' && !self.dest && !self.src) self.src = self.path
if (err && !self.dest && !self.src) return self.emit('error', err)
if (err && self.dest && !self.dest.writeHead) return self.emit('error', err)
Expand Down Expand Up @@ -153,6 +154,7 @@ function File (options) {
self.path = path.join(self.path, self.index)
self.mimetype = mimetypes.lookup(self.path.slice(self.path.lastIndexOf('.')+1))
fs.stat(self.path, finish)
return
} else {
finish(err, stats)
}
Expand All @@ -163,7 +165,7 @@ function File (options) {
} else if (self.listeners('data').length > 0) {
fs.createReadStream(self.path).pipe(self.dest)
} else {
throw new Error('Not Implemented, lazy (future) dynamic read/write discovery,')
fs.createReadStream(self.path).pipe(self)
}
}

Expand Down

0 comments on commit d9aff72

Please sign in to comment.