changeset 6000:2ce7eb7299a1

tuned editlog.news() - only open/read log if there is new stuff in it after last read position
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 11 Aug 2013 18:01:35 +0200
parents 12097531880a
children 77533e162654
files MoinMoin/logfile/editlog.py
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/logfile/editlog.py	Sat Aug 10 16:50:23 2013 +0200
+++ b/MoinMoin/logfile/editlog.py	Sun Aug 11 18:01:35 2013 +0200
@@ -243,17 +243,20 @@
         """ What has changed in the edit-log since <oldposition>?
             Returns edit-log final position() and list of changed item names.
         """
+        logsize = self.size()
         if oldposition is None:
-            self.to_end()
-        else:
+            oldposition = logsize  # == end of file
+        newposition, items = oldposition, []
+        if oldposition != logsize:
+            # looks like there is something new since we last looked...
             self.seek(oldposition)
-        items = []
-        for line in self:
-            items.append(line.pagename)
-            if line.action == 'SAVE/RENAME':
-                items.append(line.extra) # == old page name
-
-        newposition = self.position()
-        logging.log(logging.NOTSET, "editlog.news: new pos: %r new items: %r", newposition, items)
+            for line in self:
+                items.append(line.pagename)
+                if line.action == 'SAVE/RENAME':
+                    items.append(line.extra) # == old page name
+            newposition = self.position()
+            logging.log(logging.NOTSET, "editlog.news: new pos: %r new items: %r", newposition, items)
+        else:
+            logging.log(logging.NOTSET, "editlog.news: new pos: %r new items: %r (nothing new)", newposition, items)
         return newposition, items