From d04d8970751ebe2886c7237ca52238521a9b20a8 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Thu, 4 Sep 2014 17:43:31 +0100
Subject: [PATCH] [plugintools] fix size limiting in addCopySpecLimit

The backport of 029e99a did not preserve the correct behaviour
for addCopySpecLimit in sos-2.2. A missing break and incorrect
indentation of the collectExtOutput() used to obtain the 'tailed'
version of the file caused the tailing to be incorrectly applied
to all candidate files.
---
 sos/plugintools.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sos/plugintools.py b/sos/plugintools.py
index 2fd9fe6..250f724 100644
--- a/sos/plugintools.py
+++ b/sos/plugintools.py
@@ -365,11 +365,13 @@ class PluginBase:
             cursize += os.stat(flog)[ST_SIZE]
             if sizelimit and cursize > sizelimit:
                 limit_reached = True
+                break
             else:
                 self.addCopySpec(flog)
-            if limit_reached and tailit:
-                self.collectExtOutput("tail -c%d %s" % (sizelimit, flog),
-                    "tail_" + os.path.basename(flog), flog[1:])
+        if limit_reached and tailit:
+            tail_cmd = "tail -c%d %s" % (sizelimit, flog)
+            tail_out = "tail_" + os.path.basename(flog)
+            self.collectExtOutput(tail_cmd, tail_out, flog[1:])
 
     def addCopySpecs(self, copyspecs):
         if isinstance(copyspecs, basestring):
-- 
1.9.3

