Skip to content

Commit

Permalink
[stage/update] Handle putting/deleting files in series
Browse files Browse the repository at this point in the history
Bug:

    Handling the two tasks of deleting and putting files
    in parallel, on the same connection, causes issue
    as commands to handle each scenario are passed over
    and are persisted to the following actions.

    Since the same connection is used, we need some order
    in handling the files

Fix:

    The actions are handled in series. First, put then delete.
    Not parallel.

    Each of the files, in the actions, are handled in series.
    One file after the other. Not all at the same time.

References:

    * Sending multiple files: sergi/jsftp#66
  • Loading branch information
GochoMugo committed Aug 16, 2016
1 parent f943fe6 commit 0a05b3a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/stages/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const filelist = require('../filelist');
exports = module.exports = function update(globals, state, next) {
// push the changed files
function push(actionDone) {
async.each(state.diffs.changed, function(filename, done) {
async.eachSeries(state.diffs.changed, function(filename, done) {
var filepath = path.join(state.remotedir.path, filename);
globals.ftp.put(state.localdir.buffers[filename], filepath, done);
}, actionDone);
Expand All @@ -40,13 +40,13 @@ exports = module.exports = function update(globals, state, next) {
return actionDone(null);
}

async.each(state.diffs.deleted, function(filename, done) {
async.eachSeries(state.diffs.deleted, function(filename, done) {
var filepath = path.join(state.remotedir.path, filename);
globals.ftp.raw.dele(filepath, done);
}, actionDone);
}

async.parallel([
async.series([
push,
del,
], function(actionErr) {
Expand Down

0 comments on commit 0a05b3a

Please sign in to comment.