Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Prevent Paperless crash when consume folder is unavailable #629

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions src/documents/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,27 @@ def consume_new_files(self):
"""
ignored_files = []
files = []
for entry in os.scandir(self.consume):
if entry.is_file():
file = (entry.path, entry.stat().st_mtime)
if file in self._ignore:
ignored_files.append(file)
try:
for entry in os.scandir(self.consume):
if entry.is_file():
file = (entry.path, entry.stat().st_mtime)
if file in self._ignore:
ignored_files.append(file)
else:
files.append(file)
else:
files.append(file)
else:
self.logger.warning(
"Skipping %s as it is not a file",
entry.path
)

if not files:
self.logger.warning(
"Skipping %s as it is not a file",
entry.path
)

if not files:
return

except OSError:
self.logger.warning(
"Consume folder is unavailable."
)
return

# Set _ignore to only include files that still exist.
Expand Down