diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2018-09-14 10:42:07 +0200 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2018-09-14 16:36:47 +0100 |
commit | e108d7c03834446f8dac66ad69f5eade4f2c5fce (patch) | |
tree | a66a408ca86cd6dc4c64184543d49b7415c4af06 | |
parent | 8e60e299cdfb0027d6b6ea845234ef54ae785186 (diff) | |
download | sos-e108d7c03834446f8dac66ad69f5eade4f2c5fce.tar.gz |
[archive] fix and simplify directory destination rewriting
Rewriting of the destination path by _make_leading_paths() only
applies when creating intermediate path components that are a
symbolic link. The final level of path creation must always be
a directory, and the destination is always the absolute path to
that directory.
Always return the directory path when creating a new directory,
and do not attempt to rewrite the destination at the top level
in FileCacheArchive._check_path() since all intermediate links
have already been handled inside _make_leading_paths() (i.e.
the returned/rewritten destination is always equal to the path
that was passed into the function).
Resolves: #1432
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/archive.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/sos/archive.py b/sos/archive.py index e5819432..b02b75f7 100644 --- a/sos/archive.py +++ b/sos/archive.py @@ -241,6 +241,8 @@ class FileCacheArchive(Archive): else: self.log_debug("Making directory %s" % abs_path) os.mkdir(abs_path, mode) + dest = src_path + return dest def _check_path(self, src, path_type, dest=None, force=False): @@ -282,17 +284,13 @@ class FileCacheArchive(Archive): if not dest_dir: return dest - # Preserve destination basename for rewritten dest_dir - dest_name = os.path.split(src)[1] - # Check containing directory presence and path type if os.path.exists(dest_dir) and not os.path.isdir(dest_dir): raise ValueError("path '%s' exists and is not a directory" % dest_dir) elif not os.path.exists(dest_dir): src_dir = src if path_type == P_DIR else os.path.split(src)[0] - src_dir = self._make_leading_paths(src_dir) - dest = self.dest_path(os.path.join(src_dir, dest_name)) + self._make_leading_paths(src_dir) def is_special(mode): return any([ |