fmi-basel / faim-robocopy

A python-based UI for robocopy
MIT License
3 stars 0 forks source link

Consider implementing partial checksum #3

Open imagejan opened 3 years ago

imagejan commented 3 years ago

Before deleting source files, we compare files by their os.stat() signature (filecmp.cmpfiles() with default shallow=True) here:

https://github.com/fmi-basel/faim-robocopy/blob/c03980fec1ff70a036eb77e6fd2dbe4074a6d581/faim_robocopy/utils.py#L52-L54

This should be enough to also catch mismatches in creation dates (such as the 1980-01-01 ones created by Robocopy on incomplete files), but needs to be tested. We might want to offer an additional layer of safety.

Since comparing the full file contents (shallow=False) might decrease the performance too much, let's consider offering an option to compare partial checksum (e.g. on the first 128 kb) for each file, as suggested by @enricotagliavini.

/cc @lgelman