-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix directory being empty in ensure_parent_dir #260
Fix directory being empty in ensure_parent_dir #260
Conversation
2 similar comments
48d2106
to
495346f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for finding and fixing this Martin. Looks like I removed similar logic to the change you implemented when I ported the util
methods to the abstract storage backend in 8deb29f, only it wasn't a problem at the time because create_folder
would silently handle an empty string.
I have added a comment to the test you've added for this inline, otherwise this looks good to me 👍
tests/test_util.py
Outdated
# then the directory of that filepath will be an empty string. | ||
# We want to make sure that securesyslib.storage.create_folder() | ||
# won't be called with an empty string and thus raise an exception. | ||
securesystemslib.util.ensure_parent_dir('a.txt') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be simpler if we just moved this test out of the for loop, rather than adding extra handling and a large comment to the for loop. What do you think?
495346f
to
c7a4339
Compare
If you pass filename like "a.txt" to securesyslib.util.ensure_parent_dir function, then the directory of the file will be '' and when calling securesyslib.storage.create_folder() with '' argument an exception will be thrown because of the latest changes in securesyslib. Signed-off-by: Martin Vrachev <[email protected]>
c7a4339
to
247cf9b
Compare
I agree with your comment and I updated the pr with those changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thanks for resolving this.
Fixes issue #: None
Description of the changes being introduced by the pull request:
If you pass filename like "a.txt" to
securesyslib.util.ensure_parent_dir function, then the directory
of the file will be '' and when calling
securesyslib.storage.create_folder() with '' argument
an exception will be thrown because of the latest changes
in securesyslib.
Please verify and check that the pull request fulfils the following
requirements: