Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

fixup: remove helper fn 'make_dirs'

Erik Arvstedtbccac5017c29
diff --git a/src/documents/consumer.py b/src/documents/consumer.py
index cca7c1c13..37151d1b4 100644
--- a/src/documents/consumer.py
+++ b/src/documents/consumer.py
@@ -48,7 +48,7 @@ class Consumer:
self.consume = consume
self.scratch = scratch
- make_dirs(self.scratch)
+ os.makedirs(self.scratch, exists_ok=True)
if not self.consume:
raise ConsumerError(
@@ -247,11 +247,3 @@ class Consumer:
with open(doc, "rb") as f:
checksum = hashlib.md5(f.read()).hexdigest()
return Document.objects.filter(checksum=checksum).exists()
-
-
-def make_dirs(*dirs):
- for dir in dirs:
- try:
- os.makedirs(dir)
- except FileExistsError:
- pass
diff --git a/src/documents/management/commands/document_consumer.py b/src/documents/management/commands/document_consumer.py
index a0e2f00fe..4bf403318 100644
--- a/src/documents/management/commands/document_consumer.py
+++ b/src/documents/management/commands/document_consumer.py
@@ -7,7 +7,7 @@ import time
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
-from ...consumer import Consumer, ConsumerError, make_dirs
+from ...consumer import Consumer, ConsumerError
from ...mail import MailFetcher, MailFetcherError
try:
@@ -80,7 +80,8 @@ class Command(BaseCommand):
except (ConsumerError, MailFetcherError) as e:
raise CommandError(e)
- make_dirs(self.ORIGINAL_DOCS, self.THUMB_DOCS)
+ for d in (self.ORIGINAL_DOCS, self.THUMB_DOCS):
+ os.makedirs(d, exists_ok=True)
logging.getLogger(__name__).info(
"Starting document consumer at {}{}".format(