bagit-python icon indicating copy to clipboard operation
bagit-python copied to clipboard

Improve permission check performance

Open danloveg opened this issue 6 months ago • 0 comments

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.

danloveg avatar Jul 18 '25 20:07 danloveg