It depends what you mean by "simple".
On the one hand, you could make use of the file timestamps. But the problem is that timestamps can be misleading:
Checks depending on time stamps could be affected by clock skew issues. (It depends which clocks are involved, and on how clocks are managed.)
It is possible for file timestamps to be reset (e.g. by the "root" user) making it appear that a file has not changed.
It is trivial to change a "modified" file timestamp without actually changing the file; e.g. touch
.
On the other hand, if you use checksums you have other problems:
Computing a file checksum entails reading the entire file. (A partial checksum is not sufficient to detect changes, in general.) Some checksum algorithms are relatively expensive as well.
You also need to know what the previous checksum for the file was. That means that you need a way / place to store it. That could be just another file, but then you need some infrastructure to update that file (reliably) as part of the synchronization procedure.
XORing multiple checksums has the problem that you then don't know which files have changed. If one file changes you need to synchronize all of them.
It is theoretically possible for a file to change and the MD5 checksum to be the same: probability 1 in 2^128. You can probably discount this ... unless yours is a security critical application. (Note that MD5 collision attacks are practical in some contexts; see https://en.wikipedia.org/wiki/Collision_attack)
The other thing is that I suspect that you are trying to solve a solved problem. For example, the Linux / Unix rsync
utility has options to use either timestamps or (MD5) checksums to decide which files need to be synchronized.
You don't need to implement everything yourself (in Java).
In response to your "we don't have access to the old file tree" there is an easy solution to that. Each time you reboot:
- copy the file tree
- compare the current files against the copy that you made last time you rebooted.
Like I said in a comment use your imagination.