From d2c8afb13f0f2748c20cee2692a40ac6f36d61d4 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 13 Jan 2010 14:43:20 +0100 Subject: [PATCH] jqueue: Don't return negative number for unchecked jobs when archiving When the queue was empty, the calculation for unchecked jobs while archiving would return -1. ``last_touched`` is set to 0, the job ID list (``all_job_ids``) is empty. Calculating ``len(all_job_ids) - last_touched - 1`` resulted in -1. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/jqueue.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jqueue.py b/lib/jqueue.py index f989ef839..7824d3f44 100644 --- a/lib/jqueue.py +++ b/lib/jqueue.py @@ -1321,7 +1321,7 @@ class JobQueue(object): all_job_ids = self._GetJobIDsUnlocked(archived=False) pending = [] for idx, job_id in enumerate(all_job_ids): - last_touched = idx + last_touched = idx + 1 # Not optimal because jobs could be pending # TODO: Measure average duration for job archival and take number of @@ -1351,7 +1351,7 @@ class JobQueue(object): if pending: archived_count += self._ArchiveJobsUnlocked(pending) - return (archived_count, len(all_job_ids) - last_touched - 1) + return (archived_count, len(all_job_ids) - last_touched) @staticmethod def _GetJobInfoUnlocked(job, fields): -- GitLab