From 84c668f9c6e2bf708d76c94e8e19a3725ccab017 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 22 Oct 2007 05:45:58 +0000 Subject: [PATCH] Bug #184118 - Add an emaint "cleanresume" action that deletes any existing resume lists from the mtimedb. Thanks to Arfrever Frehtes Taifersar Arahesis for the initial patch. svn path=/main/trunk/; revision=8224 --- bin/emaint | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/bin/emaint b/bin/emaint index 40abc9e0d..64af1f01a 100755 --- a/bin/emaint +++ b/bin/emaint @@ -343,6 +343,54 @@ class ProgressHandler(object): def display(self): raise NotImplementedError(self) +class CleanResume(object): + def name(): + return "cleanresume" + name = staticmethod(name) + + def check(self, onProgress=None): + messages = [] + mtimedb = portage.mtimedb + resume_keys = ("resume", "resume_backup") + maxval = len(resume_keys) + if onProgress: + onProgress(maxval, 0) + for i, k in enumerate(resume_keys): + try: + d = mtimedb.get(k) + if d is None: + continue + if not isinstance(d, dict): + messages.append("unrecognized resume list: '%s'" % k) + continue + mergelist = d.get("mergelist") + if mergelist is None or not hasattr(mergelist, "__len__"): + messages.append("unrecognized resume list: '%s'" % k) + continue + messages.append("resume list '%s' contains %d packages" % \ + (k, len(mergelist))) + finally: + if onProgress: + onProgress(maxval, i+1) + return messages + + def fix(self, onProgress=None): + delete_count = 0 + mtimedb = portage.mtimedb + resume_keys = ("resume", "resume_backup") + maxval = len(resume_keys) + if onProgress: + onProgress(maxval, 0) + for i, k in enumerate(resume_keys): + try: + if mtimedb.pop(k, None) is not None: + delete_count += 1 + finally: + if onProgress: + onProgress(maxval, i+1) + if delete_count: + mtimedb.commit() + def emaint_main(myargv): # TODO: Create a system that allows external modules to be added without @@ -351,7 +399,8 @@ def emaint_main(myargv): "world" : WorldHandler, "binhost":BinhostHandler, "moveinst":MoveInstalled, - "movebin":MoveBinary + "movebin":MoveBinary, + "cleanresume":CleanResume } module_names = modules.keys() -- 2.26.2