hollow/inosync — pull request #11 by cthomas (2014-02-21 02:17:14+00:00)
Title: Enhancing subdir check to deal with substring-ed dirnames

hollow,
Just wanted to say thanks for writing inosync to start off with. It has been infinitely useful to me!

I ran up against a bug using it this evening where the comparison that is done for whether a directory in the watched paths is a subdirectory of another watched path. The check that currently exists would incorrectly detect that one of the following watched paths is a subdirectory of another watched path:
/tmp/testpath
/tmp/testpath1

This is because the current logic checks for the following conditions:
-Path1's realpath is a substring of Path2's realpath
-Path1 != Path2

The additional guard that I added checks for the following as well:
-The len(os.path.split(Path1)) <> len(os.path.split(Path2))

This guard should properly be true if Path1 were a subdirectory of Path2 since there should be a different number of elements in os.path.split between the two, but also be false in the case that the number of elements in the path is the same but the actual directory name is different.

If you wouldn't mind pulling this into the mainline, I think it would improve the overall usefulness of inosync. Also, if you want me to change anything about my patch, please let me know and I'd be happy to do so.

Thanks,
Chris Thomas