Skip to content

Commit

Permalink
Avoid deleting /dev/null when run as root (#1068)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Wood <andrew@fluidgravity.co.uk>
  • Loading branch information
jbarlow83 and andymwood committed Feb 1, 2023
1 parent 2685f91 commit 997380e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ocrmypdf/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def is_file_writable(test_file: os.PathLike) -> bool:
p = p.resolve(strict=False)

# p.is_file() throws an exception in some cases
if p.exists() and p.is_file():
if p.exists() and (p.is_file() or p.samefile(os.devnull)):
return os.access(
os.fspath(p),
os.W_OK,
Expand Down

0 comments on commit 997380e

Please sign in to comment.