MeanEYE / Sunflower

Small and highly customizable twin-panel file manager for Linux with support for plugins.
GNU General Public License v3.0
428 stars 42 forks source link

File list: Fix updating upon monitor events. #501

Closed vfaronov closed 3 years ago

vfaronov commented 3 years ago

Fixes #500.

There was a confusion between paths relative to self.path (the top level of the FileList) and to the parent (the expanded tree node). The former was passed to _delete_item_by_name, but _find_iter_by_name expected the latter. I changed it all to the latter, adding an extra parent_path parameter where necessary, as was already the case with _update_emblems_by_name, etc.

This is all brittle, there are other path-related bugs around, so working with paths should probably be refactored somehow, but so far I cannot propose or implement such a refactoring.

Along the way, I noticed and removed two unused pieces of code. if other_path is None was never taken because other_path was already being used above; and if it were somehow taken, it would mistakenly skip the updates at the end of _directory_changed.

MeanEYE commented 3 years ago

Path handling is indeed in a dire need for refactor. It's the oldest piece of code which I didn't admittedly expand properly. Right now this PR looks good but it might have some side effects. Am accepting it but might revert it in case of issues.