Fix symbolic link handling in pelican-themes -s/-c#3392
Conversation
|
@frederik-elwert: Thank you for the submission! Any thoughts from @getpelican/reviewers regarding this pull request? |
|
Thanks for the contribution. It would be nice to have a unit test. It might be pretty easy. Whatever broke before. |
Yes, I agree, it would always be good to have tests. I'm not super experienced with writing tests, and pelican-themes requires file system level interactions with the current Python environment, so I was a bit out of my depth. |
pelican-themes -s/-c
justinmayer
left a comment
There was a problem hiding this comment.
Many thanks for the fix, Frederik. I'm going to merge this now so that we can release a fix for this and thereby eliminate the problem for end users as soon as possible. If you or @boxydog can think of one or more unit tests that might prevent future regressions, submitting them in a follow-up pull request would be most appreciated. Thanks again!
Pull Request Checklist
Description
Symlinks with relative paths were not handled properly by
pelican-themes.Example:
The pelican theme to be installed is in a sibling directory to the project directory. Running
creates a symlink
../my-themein pelican’s theme folder. This link is broken, since the relative path in the symlink will now be resolved from pelican’s theme folder.When running
pelican-themes -cfrom the project folder, it will not detect the broken symlink, since the relative path will actually resolve from the current directory (just not from pelican’s theme folder).This pull request fixes this by running
os.path.realpathon the passed path both when creating symlinks and when checking symlinks. This will make sure that always the absolute paths are linked/checked.