From e108d7c03834446f8dac66ad69f5eade4f2c5fce Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Fri, 14 Sep 2018 10:42:07 +0200 Subject: [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 Signed-off-by: Bryn M. Reeves --- sos/archive.py | 8 +++----- 1 file 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([ -- cgit