Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@robinkar
Copy link
Contributor

Fixes #4714.

Dereferencing a symlink with path.realpath raises an exception if it the symlink is broken, but the exception is never rescued, causing a 0 byte zip.

However, #4715 introduced -L (--dereference), which will attempt to dereference all symlinks, which exits with exit code 1 if it encounters broken symlinks. This fixes the error handling logic for du, although I'm not 100% sure if there are cases where du exits with 1 and it is actually an error we do not want to attempt to parse the result of.

Dereferencing a symlink with path.realpath raises an exception if it the
symlink is broken, but the exception is never rescued, causing a 0 byte
zip.
du exists with status 1 if it encounters any error, e.g. a broken
symlink.

Example output seems to have been done without the -s flag.
@robinkar
Copy link
Contributor Author

Updated the implementation to not break the existing tests and added a new tests specifically for the broken symlinks, although it is only for the du check, not for the actual download.

@johrstrom johrstrom merged commit edb1d72 into OSC:master Oct 31, 2025
21 checks passed
@github-project-automation github-project-automation bot moved this from Awaiting Review to Merged/Closed in PR Review Pipeline Oct 31, 2025
@johrstrom
Copy link
Contributor

Thanks for the fix!

harshit-soora pushed a commit to harshit-soora/ondemand that referenced this pull request Oct 31, 2025
* Fix unhandled exception with broken symlink in zip

Dereferencing a symlink with path.realpath raises an exception if it the
symlink is broken, but the exception is never rescued, causing a 0 byte
zip.

* Fix du exit code check

du exists with status 1 if it encounters any error, e.g. a broken
symlink.

Example output seems to have been done without the -s flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Merged/Closed

Development

Successfully merging this pull request may close these issues.

Directories containing broken symlinks can not be downloaded

3 participants