diff --git a/README.md b/README.md index fd0374c..f102829 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/lib/client.js b/lib/client.js index ca999b7..b3813d2 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,4 +1,5 @@ var fs = require('fs'), + path = require('path'), EventEmitter = require('events').EventEmitter, inherits = require('util').inherits, FTP = require('ftp'), @@ -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) { @@ -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(); @@ -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(); });