[client] Fix bugs in index code.

Test case:
Have file "test.txt", folder with files "test" and empty folder "test2".
Move folder "test" into folder "test2".
Result: On the server, the folder "test" is not removed.