From 278a5340dc0ccd4cf7ac3d3f118e19132329900b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 4 Oct 2016 21:38:59 +0200 Subject: [PATCH] qubes/backup: fix relative path calculation os.path.relpath strip trailing '/.' from the path, but it is important to distinguish whole-directory archive (which is tar of '.'). --- qubes/backup.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qubes/backup.py b/qubes/backup.py index af95ee90..3b77f833 100644 --- a/qubes/backup.py +++ b/qubes/backup.py @@ -1026,8 +1026,8 @@ class ExtractWorker2(Process): self.tar2_process = None # if that was whole-directory archive, handle # relocated files now - inner_name = os.path.relpath( - os.path.splitext(self.tar2_current_file)[0]) + inner_name = os.path.splitext(self.tar2_current_file)[0]\ + .replace(self.base_dir + '/', '') if os.path.basename(inner_name) == '.': self.handle_dir_relocations( os.path.dirname(inner_name)) @@ -1051,7 +1051,8 @@ class ExtractWorker2(Process): # next file self.cleanup_tar2(wait=True, terminate=False) - inner_name = os.path.relpath(filename.rstrip('.000')) + inner_name = filename.rstrip('.000').replace( + self.base_dir + '/', '') redirect_stdout = None if self.relocate and inner_name in self.relocate: # TODO: add `dd conv=sparse` when removing tar layer @@ -1210,7 +1211,8 @@ class ExtractWorker3(ExtractWorker2): input_pipe.close() self.cleanup_tar2(wait=True, terminate=False) - inner_name = os.path.relpath(filename.rstrip('.000')) + inner_name = filename.rstrip('.000').replace( + self.base_dir + '/', '') redirect_stdout = None if self.relocate and inner_name in self.relocate: # TODO: add dd conv=sparse when removing tar layer