Catch error if notes directory does not exist (#4638)

This commit is contained in:
Oliver 2023-04-19 22:41:19 +10:00 committed by GitHub
parent 1b8ad70fb6
commit eafd2ac966
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()