Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# buildout files and folders
bin
.installed.cfg
eggs

# tox directory
.tox
Expand Down
4 changes: 2 additions & 2 deletions dirsync/syncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ def _compare(self, dir1, dir2):

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_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.

for ad in anc_dirs:
anc_dirs_path = os.path.join(anc_dirs_path, ad)
left.add(anc_dirs_path)

Expand Down