Initial support for non-blind aka non-batch uploads
This commit is contained in:
@@ -379,7 +379,6 @@ function getDefaultConfig() {
|
||||
],
|
||||
// :TODO: can we not just use --escape ?
|
||||
escapeTelnet : true, // set to true to escape Telnet codes such as IAC
|
||||
supportsBatch : true,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -396,8 +395,10 @@ function getDefaultConfig() {
|
||||
recvArgs : [
|
||||
'-telnet', '-8', 'rz', '{uploadDir}'
|
||||
],
|
||||
recvArgsNonBatch : [
|
||||
'-telnet', '-8', 'rz', '{fileName}'
|
||||
],
|
||||
escapeTelnet : false, // -telnet option does this for us
|
||||
supportsBatch : true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,6 +479,7 @@ function getDefaultConfig() {
|
||||
'\\b[0-3]?[0-9][\\-\\/\\.](?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|january|february|march|april|may|june|july|august|september|october|november|december)[\\-\\/\\.]((?:[0-9]{2})?[0-9]{2})\\b',
|
||||
'\\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|january|february|march|april|may|june|july|august|september|october|november|december),?\\s[0-9]+(?:st|nd|rd|th)?,?\\s((?:[0-9]{2})?[0-9]{2})\\b', // November 29th, 1997
|
||||
// :TODO: DD/MMM/YY, DD/MMMM/YY, DD/MMM/YYYY, etc.
|
||||
// :TODO: "Copyright YYYY someone"
|
||||
],
|
||||
|
||||
web : {
|
||||
|
||||
@@ -29,6 +29,7 @@ exports.Errors = {
|
||||
Invalid : (reason, reasonCode) => new EnigError('Invalid', -32004, reason, reasonCode),
|
||||
ExternalProcess : (reason, reasonCode) => new EnigError('External process error', -32005, reason, reasonCode),
|
||||
MissingConfig : (reason, reasonCode) => new EnigError('Missing configuration', -32006, reason, reasonCode),
|
||||
UnexpectedState : (reason, reasonCode) => new EnigError('Unexpected state', -32007, reason, reasonCode),
|
||||
};
|
||||
|
||||
exports.ErrorReasons = {
|
||||
|
||||
@@ -61,7 +61,7 @@ exports.getModule = class TransferFileModule extends MenuModule {
|
||||
}
|
||||
|
||||
if(options.extraArgs.recvFileName) {
|
||||
this.recvFileName = options.extraArgs.recvFiles;
|
||||
this.recvFileName = options.extraArgs.recvFileName;
|
||||
}
|
||||
|
||||
if(options.extraArgs.recvDirectory) {
|
||||
@@ -117,6 +117,28 @@ exports.getModule = class TransferFileModule extends MenuModule {
|
||||
}
|
||||
}
|
||||
|
||||
sendFiles(cb) {
|
||||
// assume *sending* can always batch
|
||||
// :TODO: Look into this further
|
||||
const allFiles = this.sendQueue.map(f => f.path);
|
||||
this.executeExternalProtocolHandlerForSend(allFiles, err => {
|
||||
if(err) {
|
||||
this.client.log.warn( { files : allFiles, error : err.message }, 'Error sending file(s)' );
|
||||
} else {
|
||||
const sentFiles = [];
|
||||
this.sendQueue.forEach(f => {
|
||||
f.sent = true;
|
||||
sentFiles.push(f.path);
|
||||
|
||||
});
|
||||
|
||||
this.client.log.info( { sentFiles : sentFiles }, `Successfully sent ${sentFiles.length} file(s)` );
|
||||
}
|
||||
return cb(err);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
sendFiles(cb) {
|
||||
// :TODO: built in/native protocol support
|
||||
|
||||
@@ -155,6 +177,7 @@ exports.getModule = class TransferFileModule extends MenuModule {
|
||||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
moveFileWithCollisionHandling(src, dst, cb) {
|
||||
//
|
||||
@@ -208,11 +231,23 @@ exports.getModule = class TransferFileModule extends MenuModule {
|
||||
this.recvFilePaths = [];
|
||||
|
||||
if(this.recvFileName) {
|
||||
//
|
||||
// file name specified - we expect a single file in |this.recvDirectory|
|
||||
|
||||
// :TODO: support non-blind: Move file to dest path, add to recvFilePaths, etc.
|
||||
// by the name of |this.recvFileName|
|
||||
//
|
||||
const recvFullPath = paths.join(this.recvDirectory, this.recvFileName);
|
||||
fs.stat(recvFullPath, (err, stats) => {
|
||||
if(err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
return cb(null);
|
||||
if(!stats.isFile()) {
|
||||
return cb(Errors.Invalid('Expected file entry in recv directory'));
|
||||
}
|
||||
|
||||
this.recvFilePaths.push(recvFullPath);
|
||||
return cb(null);
|
||||
});
|
||||
} else {
|
||||
//
|
||||
// Blind Upload (recv): files in |this.recvDirectory| should be named appropriately already
|
||||
@@ -254,8 +289,7 @@ exports.getModule = class TransferFileModule extends MenuModule {
|
||||
}
|
||||
|
||||
prepAndBuildSendArgs(filePaths, cb) {
|
||||
const external = this.protocolConfig.external;
|
||||
const externalArgs = external[`${this.direction}Args`];
|
||||
const externalArgs = this.protocolConfig.external['sendArgs'];
|
||||
|
||||
async.waterfall(
|
||||
[
|
||||
@@ -300,7 +334,8 @@ exports.getModule = class TransferFileModule extends MenuModule {
|
||||
}
|
||||
|
||||
prepAndBuildRecvArgs(cb) {
|
||||
const externalArgs = this.protocolConfig.external[`${this.direction}Args`];
|
||||
const argsKey = this.recvFileName ? 'recvArgsNonBatch' : 'recvArgs';
|
||||
const externalArgs = this.protocolConfig.external[argsKey];
|
||||
const args = externalArgs.map(arg => stringFormat(arg, {
|
||||
uploadDir : this.recvDirectory,
|
||||
fileName : this.recvFileName || '',
|
||||
|
||||
Reference in New Issue
Block a user