diff options
author | Eric Desrochers <eric.desrochers@canonical.com> | 2021-10-19 12:18:40 -0400 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-10-19 15:44:31 -0400 |
commit | 4293f3317505661e8f32ba94ad87310996fa1626 (patch) | |
tree | 944acfa3dac5c64a36d11b956f8e2bb93209e202 | |
parent | 07d96d52ef69b9f8fe1ef32a1b88089d31c33fe8 (diff) | |
download | sos-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__.py | 2 |
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) |