-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REST send before RETR if restart is used. fixes #76 #77
base: master
Are you sure you want to change the base?
Changes from 2 commits
d2bf0eb
a5c6440
ee6e194
0417a62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ var FTP = module.exports = function() { | |
this._keepalive = undefined; | ||
this._ending = false; | ||
this._parser = undefined; | ||
this._offset = undefined; | ||
this.options = { | ||
host: undefined, | ||
port: undefined, | ||
|
@@ -576,10 +577,24 @@ FTP.prototype.get = function(path, zcomp, cb) { | |
sock.destroy(); | ||
return cb(makeError(code, 'Compression not supported')); | ||
} | ||
sendRetr(); | ||
if(self._offset !== undefined){//Append at offset | ||
self._send('REST ' + self._offset, function(){ | ||
sendRetr(); | ||
self._offset = undefined; | ||
}); | ||
}else | ||
sendRetr(); | ||
}, true); | ||
} else | ||
sendRetr(); | ||
} else{ | ||
if(self._offset !== undefined){//Append at offset | ||
self._send('REST ' + self._offset, function(){ | ||
sendRetr(); | ||
self._offset = undefined; | ||
}); | ||
}else | ||
sendRetr(); | ||
} | ||
|
||
|
||
function sendRetr() { | ||
// this callback will be executed multiple times, the first is when server | ||
|
@@ -617,7 +632,14 @@ FTP.prototype.get = function(path, zcomp, cb) { | |
}; | ||
|
||
FTP.prototype.put = function(input, path, zcomp, cb) { | ||
this._store('STOR ' + path, input, zcomp, cb); | ||
self = this; | ||
if(self._offset !== undefined){ //Append at offset | ||
self._send('REST ' + self._offset, function(){ | ||
this._store('STOR ' + path, input, zcomp, cb); | ||
self._offset = undefined; | ||
}); | ||
}else | ||
this._store('STOR ' + path, input, zcomp, cb); | ||
}; | ||
|
||
FTP.prototype.append = function(input, path, zcomp, cb) { | ||
|
@@ -779,7 +801,9 @@ FTP.prototype.lastMod = function(path, cb) { | |
}; | ||
|
||
FTP.prototype.restart = function(offset, cb) { | ||
this._send('REST ' + offset, cb); | ||
self = this; | ||
self._offset = offset; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be changed to |
||
cb(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're going to keep backwards compatibility by keeping the callback-based signature, we need to at least call the callback on nextTick() instead of calling it immediately. |
||
}; | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line can be removed