Skip to content

Conversation

@j-archit
Copy link

Removes possibly redundant path and ancestor root slicing as mentioned in #42.

Test results:
Before
image

After
image

Copy link
Owner

@tkhyn tkhyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the PR and sorry for the very late review. See my comments below!

if add_path:
left.add(path)
anc_dirs = re_path[:-1].split('/')
anc_dirs = re_path.split('/')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really can't remember why the [:-1] was added here. This dates from when I completely rewrote / adapted dirsync from the original author's code. It was possibly to remove the trailing slash for directories, and I may never have hit this line with re_path being a file. However, to safe-guard against adding too many items to left, shouldn't we either use re_path.rstrip("/").split("/") or add a if not ad: continue in the for loop that follows?

anc_dirs = re_path[:-1].split('/')
anc_dirs = re_path.split('/')
anc_dirs_path = ''
for ad in anc_dirs[1:]:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we have to strip the root directory as we don't want it to appear in the left list. Same, this dates from when the module was completely rewritten back in 2014 and it looks like I did not write enough comments! Does stripping the root create issues? If yes, I would be happy to see a failing test case added to the test suite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants