jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1331674?usp=email )

Change subject: filepage: Avoid duplicate revision updates
......................................................................

filepage: Avoid duplicate revision updates

FileInfo construction already applies the supplied revision data. Avoid
updating new revisions a second time, and do not construct a throwaway
FileInfo when the timestamp is already cached.

Continue updating cached objects in place so lazily requested metadata
is merged into existing FileInfo instances.

Change-Id: I6a20800e24e2a48d083f6a1176ed304ce9057b48
---
M pywikibot/page/_filepage.py
1 file changed, 6 insertions(+), 5 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/pywikibot/page/_filepage.py b/pywikibot/page/_filepage.py
index aa5a5c2..dc31af8 100644
--- a/pywikibot/page/_filepage.py
+++ b/pywikibot/page/_filepage.py
@@ -93,11 +93,12 @@
                 continue

             ts_key = pywikibot.Timestamp.fromISOformat(file_rev['timestamp'])
-            file_revision = self._file_revisions.setdefault(
-                ts_key, FileInfo(file_rev, self))
-
-            # add new imageinfo attributes since last request.
-            file_revision.update(file_rev)
+            file_revision = self._file_revisions.get(ts_key)
+            if file_revision is None:
+                self._file_revisions[ts_key] = FileInfo(file_rev, self)
+            else:
+                # add new imageinfo attributes since last request.
+                file_revision.update(file_rev)

     @property
     def latest_file_info(self):

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1331674?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I6a20800e24e2a48d083f6a1176ed304ce9057b48
Gerrit-Change-Number: 1331674
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to