drapostolos / rdp4j

Remote Directory Poller for Java
MIT License
46 stars 25 forks source link

Comparing with last modified date is not correct !! #5

Closed rootrepo closed 9 years ago

rootrepo commented 9 years ago

Hi , I know it's easy to be critic than to develop. I don't know whether to place this under enhancement or issue. Anyhow have a look at the below SO Q&A&comments (by Thorbjørn Ravn Andersen)

http://stackoverflow.com/questions/3824983/get-latest-file-from-ftp

private boolean isFileModified(FileElementCacher file) {
        if(previousListedFiles.containsKey(file.name)){
            long current = file.lastModified;
            long previous = previousListedFiles.get(file.name).lastModified;
            return current != previous;
        }
        return false;
    }

from the discussion in SO I came to know that ,It's not correct to compare based on last modified date!!

perhaps if possible add file length into consideration. It may solve the problem!! Once again I'm not an expert, but found this when I was Analyzing the issue https://github.com/drapostolos/rdp4j/issues/4 with your code!!

cheers , Ajay

drapostolos commented 9 years ago

The SO post you refer to is regarding finding out in which order files were uploaded to the FTP server. "the "lastModified" timestamp is not linked to the FTP upload order." And as correctly stated the lastModified field is most likely not stating the time a file is uploaded.

This library (rdp4j) is used to detect when files are added, removed or modified. And can not be used for checking in which order files are uploaded to a FTP server.

This library repeatedly asks the remote side (in your case a FTP server) for the current available files and their lastModified date, in a directory. It then compares the current result with the previous result.

More specifically:

So, in other words, the statements in the SO post does not apply for rdp4j. I hope this was clear?