Skip to content

Conversation

@danloveg
Copy link

I saw a "TODO" in the code regarding a redundant os.walk operation when checking whether a Bag can actually be created or not, which this pull request addresses.

I've combined _can_bag and _can_read into one function that walk()s through the bag directory at most once (instead of twice). Additionally, I am raising an exception when an unreadable/unwriteable file/dir is encountered. This is opposed to the previous method of compiling a complete list of all unreadable/unwriteable items, printing them, and then throwing an exception. The offending file name is now included in the exception rather than returned in a tuple.

Combines _can_bag and _can_read into one function. Instead of compiling
a list of every single file and directory that cannot be read/written
to, this new function throws an Exception as soon as a problematic file
or directory comes up.

At most, one walk() operation is completed now, instead of two.
This message said to do do permission checks before changing
directories, which is already how the code behaves.
@danloveg danloveg force-pushed the combine-can-bag-can-read branch from 01f2561 to c144ce1 Compare December 26, 2025 16:41
@danloveg
Copy link
Author

Fixed merge conflicts on this branch

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