mirror of
https://github.com/kirill-markin/repo-to-text.git
synced 2025-12-06 03:22:23 -08:00
Add minimal handling for broken symlinks in generate_output_content
This commit is contained in:
parent
de1c84eca3
commit
2475609834
1 changed files with 10 additions and 0 deletions
|
|
@ -427,6 +427,16 @@ def generate_output_content(
|
||||||
with open(file_path, 'rb') as f_bin:
|
with open(file_path, 'rb') as f_bin:
|
||||||
binary_content: bytes = f_bin.read()
|
binary_content: bytes = f_bin.read()
|
||||||
_add_chunk_to_output(binary_content.decode('latin1')) # Add decoded binary
|
_add_chunk_to_output(binary_content.decode('latin1')) # Add decoded binary
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
# Minimal handling for bad symlinks
|
||||||
|
if os.path.islink(file_path) and not os.path.exists(file_path):
|
||||||
|
try:
|
||||||
|
target = os.readlink(file_path)
|
||||||
|
except OSError:
|
||||||
|
target = ''
|
||||||
|
_add_chunk_to_output(f"[symlink] -> {target}")
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
|
|
||||||
_add_chunk_to_output('\n</content>\n')
|
_add_chunk_to_output('\n</content>\n')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue