From 2fe7df8ca06180dbb6e99efedde300abe34ed995 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Fri, 11 May 2018 14:01:13 +0200 Subject: [PATCH] Consume documents in order of increasing mtime This increases overall usability, especially for multi-page scans. Previously, the consumption order was undefined (see os.listdir()) --- src/documents/consumer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/documents/consumer.py b/src/documents/consumer.py index fc8635c95..3d7cc7bd1 100644 --- a/src/documents/consumer.py +++ b/src/documents/consumer.py @@ -71,8 +71,11 @@ class Consumer: }) def run(self): + docs = [os.path.join(self.consume, entry) + for entry in os.listdir(self.consume)] + docs_old_to_new = sorted(docs, key=lambda doc: os.path.getmtime(doc)) - for doc in os.listdir(self.consume): + for doc in docs_old_to_new: doc = os.path.join(self.consume, doc)