aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Desrochers <eric.desrochers@canonical.com>2021-10-19 12:18:40 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-10-19 15:44:31 -0400
commit4293f3317505661e8f32ba94ad87310996fa1626 (patch)
tree944acfa3dac5c64a36d11b956f8e2bb93209e202
parent07d96d52ef69b9f8fe1ef32a1b88089d31c33fe8 (diff)
downloadsos-4293f3317505661e8f32ba94ad87310996fa1626.tar.gz
[report] check for symlink before rmtree when opt estimate-only is use
Check if the dir is also symlink before performing rmtree() method so that unlink() method can be used instead. Traceback (most recent call last): File "./bin/sos", line 22, in <module> sos.execute() File "/tmp/sos/sos/__init__.py", line 186, in execute self._component.execute() OSError: Cannot call rmtree on a symbolic link Closes: #2727 Signed-off-by: Eric Desrochers <eric.desrochers@canonical.com>
-rw-r--r--sos/report/__init__.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/sos/report/__init__.py b/sos/report/__init__.py
index 7feb31ee..1b5bc97d 100644
--- a/sos/report/__init__.py
+++ b/sos/report/__init__.py
@@ -1059,7 +1059,7 @@ class SoSReport(SoSComponent):
# deletion of some dirs but deleting their content
for f in os.listdir(self.archive.get_tmp_dir()):
f = os.path.join(self.archive.get_tmp_dir(), f)
- if os.path.isdir(f):
+ if os.path.isdir(f) and not os.path.islink(f):
rmtree(f)
else:
os.unlink(f)