Solved : CFFTP returns wrong LastModified Date

Unexpectedly knocked my head on a pretty ugly "bug" yesterday - not sure actually if that is a CF bug or not - but I guess this is something that CF should have handled, so I am tentatively blaming CF bellow. Quick Google search revealed people have been complaining about this since 2005 (I'm on CF9).

I was trying to FTP into a folder and figure out new files/folders that has been created within last hour. Take a look at the (ABC) folder, it is stamped with the date "1/29/2013"


(Screenshot of Filezilla)

I used CFFTP tag to call the same FTP server:

   1: <cfftp server="myftp-server" name="getftp" username="ftpuser" password="*******" action="listDir" directory="incoming">
   2: <cfdump var="#getftp#">
Show/Hide Line Numbers . Full Screen . Plain



Look at the (ABC) folder's last modified date. It is 2012-01-29, it is off by a year. But other folders are 2012 too, not enough information to find a pattern here.

Next I jumped into Java and did the same thing.

   1: <cfset test = CreateObject("java",'org.apache.commons.net.ftp.FTPClient') >
   2: <cfset test.connect("ftpserver")>
   3: <cfset test.login("ftpuser", "*******")>
   4: <cfdump var="#test.listFiles('incoming')[1].getName()#">
   5: <cfdump var="#test.listFiles('incoming')[1].getTimestamp().getTime()#">
Show/Hide Line Numbers . Full Screen . Plain

This gave me ABC {ts '2012-01-29 16:12:00'}

Just as I thought there was no difference. This is why I am tiny bit reluctant to blame CF first, but I ran the same code in Railo and it gave me the correct dates:



I did not tried this with CF10 yet. Also I did not tried with other FTP servers. It is very possible this issue happens only with some FTP server software (It is CentOS here). For the time been this remains unsolved.

Update (Jan 20 1213)

Finally I figured out a workaround. I'm not sure is it quite brilliant or pathetic solution, I guess both.

I copied apache-jakarta-commons-net.jar from my Railo server into my Adobe CF application folder, load it with JavaLoader. And now my Adobe CF work as much as good as Railo.

   1: <cfset paths = arrayNew(1)>
   2: <cfset paths[1] = expandPath("apache-jakarta-commons-net.jar")>
   3: <cfset loader = createObject("component", "javaloader.JavaLoader").init(paths)>
   4: <cfset test = loader.create('org.apache.commons.net.ftp.FTPClient') >
   5: <cfset test.connect("FTP.my ftp serer.com")>
   6: <cfset test.login("ftpuser", "*************")>
   7: <cfdump var="#test.listFiles('incoming')[1].getName()#">
   8: <cfdump var="#test.listFiles('incoming')[1].getTimestamp().getTime()#">
Show/Hide Line Numbers . Full Screen . Plain

By the way, you can download the library here (commons-net-3.2.jar) instead copying from Railo.

2 Comments :
Wednesday 30 January 2013 12:16 PM
Did you file a bug report for it? It may be old, but if everyone complained but didn't file it... Adobe wouldn't know. :)
Wednesday 30 January 2013 12:27 PM
I did now :)