aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2017-09-24 13:52:57 +0200
committerBryn M. Reeves <bmr@redhat.com>2017-11-01 11:47:20 +0000
commit4229326964c05e9caf617ac89e1ec69ab4b5c979 (patch)
tree59c1d28d06258fde88b46c8324e4041c042df668
parent2be61709f22363cf927d77b0977b5dae3a33a197 (diff)
downloadsos-4229326964c05e9caf617ac89e1ec69ab4b5c979.tar.gz
[plugins] Don't tail gzipped files when reaching sizelimit
In case sizelimit in add_copy_spec is reached and tailit=True, we shall skip tailing a gzip archive that would be collected as damaged. Resolves: #907 Signed-off-by: Pavel Moravec <pmoravec@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 632e2f5f..28c6f197 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -81,6 +81,16 @@ def _node_type(st):
return t[1]
+def _file_is_compressed(path):
+ """Check if a file appears to be compressed
+
+ Return True if the file specified by path appears to be compressed,
+ or False otherwise by testing the file name extension against a
+ list of known file compression extentions.
+ """
+ return path.endswith(('.gz', '.xz', '.bz', '.bz2'))
+
+
class Plugin(object):
""" This is the base class for sosreport plugins. Plugins should subclass
this and set the class variables where applicable.
@@ -564,7 +574,7 @@ class Plugin(object):
break
self._add_copy_paths([_file])
- if limit_reached and tailit:
+ if limit_reached and tailit and not _file_is_compressed(_file):
file_name = _file
if file_name[0] == os.sep: