switch .is_dir and .exists for os.access to avoid PermissionError on startup

This commit is contained in:
Nick Sweeting 2024-10-08 03:02:34 -07:00
parent c3dd0f22e5
commit de2ab43f7f
No known key found for this signature in database
22 changed files with 119 additions and 97 deletions

View file

@ -149,12 +149,13 @@ def save_text_as_source(raw_text: str, filename: str='{ts}-stdin.txt', out_dir:
referenced_texts = ''
for entry in raw_text.split():
try:
if Path(entry).exists():
referenced_texts += Path(entry).read_text()
except Exception as err:
print(err)
# dont attempt to read local files from the text, security risk:
# for entry in raw_text.split():
# try:
# if Path(entry).exists():
# referenced_texts += Path(entry).read_text()
# except Exception as err:
# print(err)
atomic_write(source_path, raw_text + '\n' + referenced_texts)
log_source_saved(source_file=source_path)