Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
add options.hardlinks boolean for treating hardlinks as Link or File
Browse files Browse the repository at this point in the history
  • Loading branch information
max-mapper authored and isaacs committed Nov 20, 2013
1 parent 695b85e commit 40311b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/dir-reader.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ DirReader.prototype.getChildProps = function (stat) {
, follow: this.follow , follow: this.follow
, filter: this.filter , filter: this.filter
, sort: this.props.sort , sort: this.props.sort
, hardlinks: this.props.hardlinks
} }
} }


Expand Down
5 changes: 3 additions & 2 deletions lib/reader.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ Reader.prototype._stat = function (currentStat) {
var me = this var me = this
, props = me.props , props = me.props
, stat = props.follow ? "stat" : "lstat" , stat = props.follow ? "stat" : "lstat"

// console.error("Reader._stat", me._path, currentStat) // console.error("Reader._stat", me._path, currentStat)
if (currentStat) process.nextTick(statCb.bind(null, null, currentStat)) if (currentStat) process.nextTick(statCb.bind(null, null, currentStat))
else fs[stat](me._path, statCb) else fs[stat](me._path, statCb)
Expand All @@ -163,8 +162,10 @@ Reader.prototype._stat = function (currentStat) {
me.size = props.size me.size = props.size


var type = getType(props) var type = getType(props)
var handleHardlinks = props.hardlinks !== false

// special little thing for handling hardlinks. // special little thing for handling hardlinks.
if (type !== "Directory" && props.nlink && props.nlink > 1) { if (handleHardlinks && type !== "Directory" && props.nlink && props.nlink > 1) {
var k = props.dev + ":" + props.ino var k = props.dev + ":" + props.ino
// console.error("Reader has nlink", me._path, k) // console.error("Reader has nlink", me._path, k)
if (hardLinks[k] === me._path || !hardLinks[k]) hardLinks[k] = me._path if (hardLinks[k] === me._path || !hardLinks[k]) hardLinks[k] = me._path
Expand Down

0 comments on commit 40311b5

Please sign in to comment.