Skip to content

Commit

Permalink
Handle OSError when creating directories with a log message instead…
Browse files Browse the repository at this point in the history
… of crashing
  • Loading branch information
ewels committed Oct 3, 2022
1 parent 462fcd4 commit c8716d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog: rich-codex

## Version 1.2.6 (2022-10-03)

- 🐛 Handle `OSError` when creating directories with a log message instead of crashing

## Version 1.2.5 (2022-08-25)

- 🐛 Tweak output whitespace, fix use of `Path.absolute()` ([#39](https://github.com/ewels/rich-codex/pull/39))
Expand Down
2 changes: 1 addition & 1 deletion src/rich_codex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
for use with the rich-codex GitHub Action.
"""

__version__ = "1.2.5"
__version__ = "1.2.6"

from rich_codex import rich_img # noqa: F401
6 changes: 5 additions & 1 deletion src/rich_codex/rich_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,11 @@ def save_images(self):
for filename in self.img_paths:

# Make directories if necessary
Path(filename).parent.mkdir(parents=True, exist_ok=True)
try:
Path(filename).parent.mkdir(parents=True, exist_ok=True)
except OSError:
log.error(f"Invalid path: {filename}")
continue

# If already made this image, copy it from the last destination
if filename.lower().endswith(".png") and png_img is not None:
Expand Down

0 comments on commit c8716d1

Please sign in to comment.