From eafd2ac966249c95646794f50962361b0c6d6f41 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 19 Apr 2023 22:41:19 +1000 Subject: [PATCH] Catch error if notes directory does not exist (#4638) --- InvenTree/common/tasks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/InvenTree/common/tasks.py b/InvenTree/common/tasks.py index 80e73e9a1c..11dd5d4441 100644 --- a/InvenTree/common/tasks.py +++ b/InvenTree/common/tasks.py @@ -118,7 +118,11 @@ def delete_old_notes_images(): # Finally, remove any images in the notes dir which are not linked to a note notes_dir = os.path.join(settings.MEDIA_ROOT, 'notes') - images = os.listdir(notes_dir) + try: + images = os.listdir(notes_dir) + except FileNotFoundError: + # Thrown if the directory does not exist + images = [] all_notes = NotesImage.objects.all()