Skip to content
Permalink
Browse files
fix parseEntry#parsers.msdos bug,when dir name is numbers,it will be …
…read as file
  • Loading branch information
keel committed Nov 7, 2015
1 parent 6412199 commit 0b130bc927afec17c593f5b276a434d0a11e6e68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
@@ -1,3 +1,4 @@
.DS_Store
.idea
node_modules
reports
@@ -52,6 +52,13 @@ var RE_UnixEntry = new RegExp(
var RE_DOSEntry = new RegExp(
"(\\S+)\\s+(\\S+)\\s+" +
"(<DIR>)?\\s*" +
// "([0-9]+)?\\s*" +
"(\\S.*)"
);
// fix: RE_DOSEntry2 for dir is numbers
var RE_DOSEntry2 = new RegExp(
"(\\S+)\\s+(\\S+)\\s+" +
// "(<DIR>)?\\s*" +
"([0-9]+)?\\s*" +
"(\\S.*)"
);
@@ -265,7 +272,9 @@ var parsers = {
},

msdos: function(entry) {
var group = entry.match(RE_DOSEntry);
var isDir = (entry.indexOf('<DIR>') > 0);
var regx = isDir ? RE_DOSEntry : RE_DOSEntry2;
var group = entry.match(regx);
var type;

if (!group) {
@@ -278,19 +287,18 @@ var parsers = {

var time = group[2].replace(/(\d{2}):(\d{2})([AP]M)/, replacer);
var date = new Date(group[1] + " " + time).getTime();
var dirString = group[3];
var size = group[4];
var name = group[5];
var size = group[3] || 0;
var name = group[4];

if (null == name || name === "." || name === "..") {
return null;
}

if (dirString === "<DIR>") {
if (isDir) {
type = exports.nodeTypes.DIRECTORY_TYPE;
size = 0;
}
else {

}else {
type = exports.nodeTypes.FILE_TYPE;
}

3 comments on commit 0b130bc

@keel
Copy link
Owner Author

@keel keel commented on 0b130bc Nov 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the remote dir is numbers, it will be parsed as file.
ftp server is Windows.

@Xuanwo
Copy link

@Xuanwo Xuanwo commented on 0b130bc Dec 21, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, this problem only display on win server?
And had the upsteam fixed this bug yet?

@littlesevenmo
Copy link

@littlesevenmo littlesevenmo commented on 0b130bc Oct 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

您好,我也遇到了您曾经遇到的问题,按照您的方式结果还是有问题。

PS D:\Blog\test4> hexo d
INFO  Validating config
INFO  Deploying: ftpsync
Setup
Setup complete.

Collecting
events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on  instance at:
    at Stream.<anonymous> (D:\Blog\test4\node_modules\jsftp\lib\jsftp.js:91:32)
    at Stream.emit (events.js:400:28)
    at Socket.reemit (D:\Blog\test4\node_modules\duplexer\index.js:85:16)
    at Socket.emit (events.js:400:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}

Please sign in to comment.