← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:sync-signingkeys-more-commits into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:sync-signingkeys-more-commits into launchpad:master.

Commit message:
sync-signingkeys: Abort/commit after each archive

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/392614

If we only abort/commit at the end, then running over all archives results in an extremely long transaction that may time out.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:sync-signingkeys-more-commits into launchpad:master.
diff --git a/lib/lp/archivepublisher/scripts/sync_signingkeys.py b/lib/lp/archivepublisher/scripts/sync_signingkeys.py
index b535875..f8d05f0 100644
--- a/lib/lp/archivepublisher/scripts/sync_signingkeys.py
+++ b/lib/lp/archivepublisher/scripts/sync_signingkeys.py
@@ -246,12 +246,13 @@ class SyncSigningKeysScript(LaunchpadScript):
                 self.injectGPG(archive, secret_key_path)
 
     def main(self):
-        for i, archive in enumerate(self.getArchives()):
+        archives = list(self.getArchives())
+        for i, archive in enumerate(archives):
             self.logger.debug(
                 "#%s - Processing keys for archive %s.", i, archive.reference)
             self.processArchive(archive)
-        if self.options.dry_run:
-            transaction.abort()
-        else:
-            transaction.commit()
+            if self.options.dry_run:
+                transaction.abort()
+            else:
+                transaction.commit()
         self.logger.info("Finished processing archives injections.")