Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gideonthomas committed Oct 21, 2014
1 parent 019b527 commit da60fba
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 40 deletions.
4 changes: 3 additions & 1 deletion client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ function createFS(options) {
var autoSync;
var pathCache;

// Path needed to be upstreamed during a downstream sync
// Path that needs to be used for an upstream sync
// to sync files that were determined to be more
// up-to-date on the client during a downstream sync
var upstreamPath;

// State of the sync connection
Expand Down
16 changes: 7 additions & 9 deletions client/src/message-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ function handleResponse(syncManager, data) {
return callback(err);
}

// Non-existent paths (usually due to renames or
// deletes that are included in the syncedPaths)
// cannot be stamped with a checksum
return callback();
}

Expand All @@ -149,19 +152,14 @@ function handleResponse(syncManager, data) {
return callback(err);
}

fsUtils.setChecksum(fs, path, checksum, function(err) {
if(err) {
return callback(err);
}

callback();
});
fsUtils.setChecksum(fs, path, checksum, callback);
});
});
}

// Store the checksums of the upstream synced files
// as xattrs on the file
// As soon as an upstream sync happens, the files synced
// become the last synced versions and must be stamped
// with their checksums to version them
async.eachSeries(syncedPaths, stampChecksum, function(err) {
if(err) {
return onError(syncManager, err);
Expand Down
32 changes: 4 additions & 28 deletions lib/fs-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,10 @@ function fremoveUnsynced(fs, fd, callback) {

// Set the unsynced metadata for a path
function setUnsynced(fs, path, callback) {
fs.setxattr(path, constants.attributes.unsynced, Date.now(), function(err) {
if(err) {
return callback(err);
}

callback();
});
fs.setxattr(path, constants.attributes.unsynced, Date.now(), callback);
}
function fsetUnsynced(fs, fd, callback) {
fs.fsetxattr(fd, constants.attributes.unsynced, Date.now(), function(err) {
if(err) {
return callback(err);
}

callback();
});
fs.fsetxattr(fd, constants.attributes.unsynced, Date.now(), callback);
}

// Get the unsynced metadata for a path
Expand Down Expand Up @@ -119,22 +107,10 @@ function fremoveChecksum(fs, fd, callback) {

// Set the Checksum metadata for a path
function setChecksum(fs, path, checksum, callback) {
fs.setxattr(path, constants.attributes.checksum, checksum, function(err) {
if(err) {
return callback(err);
}

callback();
});
fs.setxattr(path, constants.attributes.checksum, checksum, callback);
}
function fsetChecksum(fs, fd, checksum, callback) {
fs.fsetxattr(fd, constants.attributes.checksum, checksum, function(err) {
if(err) {
return callback(err);
}

callback();
});
fs.fsetxattr(fd, constants.attributes.checksum, checksum, callback);
}

// Get the Checksum metadata for a path
Expand Down
2 changes: 1 addition & 1 deletion lib/rsync/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ module.exports = function patch(fs, path, diffList, options, callback) {
}

// If the file was modified before the
// diffNode's modified time, it is outdated
// diffNode's modified time, the file is outdated
// and needs to be patched
if(stats.mtime <= diffNode.modified) {
return applyPatch(getPatchedData(data));
Expand Down
6 changes: 5 additions & 1 deletion lib/rsync/rsync-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ function roll(data, checksums, blockSize) {
return results;
}

// RSync function to calculate checksums
// Rsync function to calculate checksums for
// a file by dividing it into blocks of data
// whose size is passed in and checksuming each
// block of data
function blockChecksums(fs, path, size, callback) {
var cache = {};

Expand Down Expand Up @@ -249,6 +252,7 @@ function blockChecksums(fs, path, size, callback) {
}

// Generate the MD5 hash for the data of a file
// in its entirety
function getChecksum(fs, path, callback) {
fs.readFile(path, function(err, data) {
if(!err) {
Expand Down

0 comments on commit da60fba

Please sign in to comment.