From 39c51e8b042802cd3ca367ebb01015c8cdfb48a7 Mon Sep 17 00:00:00 2001 From: gideonthomas Date: Mon, 18 Aug 2014 12:25:09 -0400 Subject: [PATCH] Allow checksum to be called without changing the context of the this object --- lib/rsync.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/rsync.js b/lib/rsync.js index 0793d07..802d406 100644 --- a/lib/rsync.js +++ b/lib/rsync.js @@ -216,10 +216,10 @@ function roll(data, checksums, chunkSize) { } // RSync function to calculate checksums -function checksum (path, size, callback) { +function checksum (fs, path, size, callback) { var cache = {}; - this.readFile(path, function (err, data) { + fs.readFile(path, function (err, data) { if (!err) { // cache file cache[path] = data; @@ -441,7 +441,7 @@ rsync.checksums = function(fs, path, srcList, options, callback) { nodeChecksums.push(nodeChecksum); callback(); } else { - checksum.call(fs, absPath, options.size, function(err, checksums) { + checksum(fs, absPath, options.size, function(err, checksums) { if(err) { return callback(err); } @@ -455,7 +455,7 @@ rsync.checksums = function(fs, path, srcList, options, callback) { } }); } else { - checksum.call(fs, absPath, options.size, function(err, checksums) { + checksum(fs, absPath, options.size, function(err, checksums) { if(err) { return callback(err); } @@ -967,7 +967,7 @@ rsync.pathChecksums = function(fs, paths, chunkSize, callback) { } // Calculate checksums for file or symbolic links - checksum.call(fs, path, chunkSize, function(err, chksum) { + checksum(fs, path, chunkSize, function(err, chksum) { if(err) { return callback(err); } @@ -1065,7 +1065,7 @@ rsync.compareContents = function(fs, checksums, chunkSize, callback) { } // Compare checksums for two files/symbolic links - checksum.call(fs, path, chunkSize, function(err, checksum) { + checksum(fs, path, chunkSize, function(err, checksum) { if(err) { return callback(err); }