From 14bb52b6a45ca49d5c7ed918bbb215978e018367 Mon Sep 17 00:00:00 2001 From: Daniel Quinn Date: Sun, 7 Oct 2018 13:12:22 +0100 Subject: [PATCH] Wrap document consumption in a transaction #262 --- src/documents/consumer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/documents/consumer.py b/src/documents/consumer.py index 28fc28f9e..7dd94ebf1 100644 --- a/src/documents/consumer.py +++ b/src/documents/consumer.py @@ -1,3 +1,4 @@ +from django.db import transaction import datetime import hashlib import logging @@ -111,8 +112,11 @@ class Consumer: if not self.try_consume_file(file): self._ignore.append((file, mtime)) + @transaction.atomic def try_consume_file(self, file): - "Return True if file was consumed" + """ + Return True if file was consumed + """ if not re.match(FileInfo.REGEXES["title"], file): return False