evanplaice / node-ftpsync

Intelligent file syncronization over FTP
http://evanplaice.github.io/node-ftpsync
MIT License
74 stars 21 forks source link

change isDifferent function #13

Closed Nerom closed 9 years ago

Nerom commented 9 years ago

when the rfile is the same size with lfile , but the content is different , wen need to compare their timestamp either

Nerom commented 9 years ago

sorry,@evanplaice , I did test my code, and it work well and correctly,But I did not think about the different time zones, It's my fault. I'm a newbie with node, I don't know how to modify your code correctly this time.I'm waiting for your modification!

evanplaice commented 9 years ago

It's not an easy issue to resolve and that's why I don't have a fully fleshed-out solution.

One approach that seems the most sensible is to create a temp file of 0 bytes that is uploaded to the server. The file modification time is read by sending a MDTM request to the server (ie it should be supported by any FTP server that fully implements the FTP protocol). Then compare the remote tmp file to the local temp file to calculate the offset.

The problem is, not all ftp servers support MTDM requests because - while ftp is a fully specified RFC standard - it's not not supported by all FTP servers.

I made decent progress on this issue in the past but the node FTP server implementation (ie ftpd) that I use for testing didn't previously support MDTM requests. I contributed a fix to the project so it should work now but the code of this project that uses timestamps for comparisons should work whether or not the server supports MDTM requests.

These are the difficult problems that arise with creating a universal library. It has to support everybody, including people that are communicating with half-baked server implementations.

Here's how it should work:

Time comparisons are handled in the manner that file size comparisons occur. It's not an easy problem to fix but the code is already partially implemented. This specific feature was next on the list because I was already half way to developing a solution.

Ideally, the 'best' solution would use MDTM to handle the comparison and fall back to a 'dumber' approach if MDTM is not supported by the remote FTP server. This PR won't fix the issue but only because there's no simple solution.

Nerom commented 9 years ago

So complicated , I think I can't commit a patch , I'll wait for your update. By the way excellent job !