зеркало из https://github.com/mozilla/makedrive.git
Allow checksum to be called without changing the context of the this object
This commit is contained in:
Родитель
f2496c2a5b
Коммит
39c51e8b04
12
lib/rsync.js
12
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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче