Ensure docs have been unmodified for some time before consuming

Previously, the second mtime check for new files usually happened right
after the first one, which could have caused consumption of docs that
were still being modified.

We're now waiting for at least FILES_MIN_UNMODIFIED_DURATION (0.5s).

This also cleans up the logic by eliminating the consumer.stats attribute
and the weird double call to consumer.run().

Additionally, this a fixes memory leak in consumer.stats where paths could be
added but never removed if the corresponding files disappeared from
the consumer dir before being considered ready.
This commit is contained in:
Erik Arvstedt
2018-05-11 14:01:16 +02:00
parent 0db6ed225b
commit f56ec70aad
2 changed files with 30 additions and 37 deletions

View File

@@ -95,7 +95,4 @@ class Command(BaseCommand):
self.first_iteration = False
self.mail_fetcher.pull()
# Consume whatever files we can.
# We have to run twice as the first run checks for file readiness
for i in range(2):
self.file_consumer.run()
self.file_consumer.consume_new_files()