Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ and the `options` object may contain the following keys:

* *logging* (String): 'none', 'basic', 'debug' - level of logging for all the tasks - use 'debug' in case of any issues
* *overwrite* (String): 'none', 'older', 'all' - determines which files should be overwritten when downloading/uploading - 'older' compares the date of modification of local and remote files
* *testingTimezoneDir* (String): default null - using default home directory if null. The directory should have Read/Write permission in order to adjust timezone for overwriting files.

### Connecting
After creating the new object you have to manually connect to the server by using the `connect` method:
Expand Down
13 changes: 9 additions & 4 deletions lib/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var fs = require('fs'),
path = require('path'),
EventEmitter = require('events').EventEmitter,
inherits = require('util').inherits,
FTP = require('ftp'),
Expand Down Expand Up @@ -27,7 +28,8 @@ Client = module.exports = function (config, options) {
});

this.options = _.defaults(options || {}, {
overwrite: 'older' // | 'all' | 'none'
overwrite: 'older', // | 'all' | 'none'
testingTimezoneDir: null, // using default home directory if null. NOTE: this directory need has Read/Write permission
});

if (this.options.logging) {
Expand Down Expand Up @@ -422,15 +424,18 @@ Client.prototype._checkTimezone = function (cb) {
serverTime,
ftp = this.ftp;

var timestampPath = '.timestamp';
timestampPath = this.options.testingTimezoneDir?path.join(this.options.testingTimezoneDir, timestampPath):timestampPath;

async.series([
function (next) {
return ftp.put(new Buffer(''), '.timestamp', function (err) {
return ftp.put(new Buffer(''), timestampPath, function (err) {
if (err) log(err, 'debug');
next();
});
},
function (next) {
return ftp.list('.timestamp', function (err, list) {
return ftp.list(timestampPath, function (err, list) {
if (err) log(err, 'debug');
if (list && list[0] && list[0].date) {
serverTime = list[0].date.getTime();
Expand All @@ -439,7 +444,7 @@ Client.prototype._checkTimezone = function (cb) {
});
},
function (next) {
return ftp.delete('.timestamp', function (err) {
return ftp.delete(timestampPath, function (err) {
if (err) log(err, 'debug');
next();
});
Expand Down