[ 
https://issues.apache.org/jira/browse/NET-574?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14592347#comment-14592347
 ] 

Nicolas Leclerc commented on NET-574:
-------------------------------------

Strange :
{noformat}
$ java -jar commons-net-examples-3.3.jar FTPClientExample -t xxxx.yyyy.fr 
mylogin passwd data
220 ProFTPD 1.3.4a Server (xxxx) [::ffff:10.10.10.10]
Connected to xxxx.yyyy.fr on 21
USER *******
331 Password required for mylogin
PASS *******
230 User mylogin logged in
SYST
215 UNIX Type: L8
Remote system is UNIX Type: L8
TYPE A
200 Type set to A
MLST data
250-Start of list for data
250-modify=20150616154133;perm=flcdmpe;type=dir;unique=20U8FE0390;UNIX.group=32;UNIX.mode=02755;UNIX.owner=2005;
 /data
250 End of list
drwxr-xr-x    0 32       2005           -1 /data
NOOP
200 NOOP command successful
QUIT
221 Goodbye.
{noformat}

> FTPClient.mlistFile returns null timestamps in FTPFile.getTimestamp
> -------------------------------------------------------------------
>
>                 Key: NET-574
>                 URL: https://issues.apache.org/jira/browse/NET-574
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.3
>         Environment: On Debian linux with proftpd server
>            Reporter: Nicolas Leclerc
>
> In FTPClient mlistFile("test.txt") :
> {code:title=FTPClient.java|borderStyle=solid}
>     public FTPFile mlistFile(String pathname) throws IOException
>     {
>         boolean success = 
> FTPReply.isPositiveCompletion(sendCommand(FTPCmd.MLST, pathname));
>         if (success){
>             String entry = getReplyStrings()[1].substring(1); // skip leading 
> space for parser
>             return MLSxEntryParser.parseEntry(entry);
>         } else {
>             return null;
>         }
>     }
> {code}
> getReplyStrings() return :
> 250-Start of list for test.txt
> 250-modify=20150616133640;perm=adfrw;size=83752220;type=file;unique=23U8FE039C;UNIX.group=32;UNIX.mode=0644;UNIX.owner=2005;
>  /data/test.txt
> 250 End of list
> So getReplyStrings()[1].substring(1) return 
> 50-modify=20150616133640;perm=adfrw;size=83752220;type=file;unique=23U8FE039C;UNIX.group=32;UNIX.mode=0644;UNIX.owner=2005;
>  /data/test.txt
> {code:title=MLSxEntryParser.java|borderStyle=solid}
> public FTPFile parseFTPEntry(String entry) {
>         String parts[] = entry.split(" ",2); // Path may contain space
>         if (parts.length != 2) {
>             return null;
>         }
>         FTPFile file = new FTPFile();
>         file.setRawListing(entry);
>         file.setName(parts[1]);
>         String[] facts = parts[0].split(";");
>         boolean hasUnixMode = 
> parts[0].toLowerCase(Locale.ENGLISH).contains("unix.mode=");
>         for(String fact : facts) {
>             String []factparts = fact.split("=");
> // Sample missing permission
> // drwx------   2 mirror   mirror       4096 Mar 13  2010 subversion
> // 
> modify=20100313224553;perm=;type=dir;unique=811U282598;UNIX.group=500;UNIX.mode=0700;UNIX.owner=500;
>  subversion
>             if (factparts.length != 2) {
>                 continue; // nothing to do here
>             }
>             String factname = factparts[0].toLowerCase(Locale.ENGLISH);
>             String factvalue = factparts[1];
>             String valueLowerCase = factvalue.toLowerCase(Locale.ENGLISH);
>             if ("size".equals(factname)) {
>                 file.setSize(Long.parseLong(factvalue));
>             }
>             else if ("sizd".equals(factname)) { // Directory size
>                 file.setSize(Long.parseLong(factvalue));
>             }
>             else if ("modify".equals(factname)) {
> (...)
> {code}
> 50-modify not correspond to modify, so the parser not find the date
> Possible patch :
> {code:title=FTPClient.java|borderStyle=solid}
>     public FTPFile mlistFile(String pathname) throws IOException
>     {
>         boolean success = 
> FTPReply.isPositiveCompletion(sendCommand(FTPCmd.MLST, pathname));
>         if (success){
>             String entry = getReplyStrings()[1].substring(4); // skip leading 
> (...)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to