Allow checksum to be called without changing the context of the this object

This commit is contained in:
gideonthomas 2014-08-18 12:25:09 -04:00
Родитель f2496c2a5b
Коммит 39c51e8b04
1 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -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);
}