From 007df06657db1bfe8ff73b725abd654f3d9954eb Mon Sep 17 00:00:00 2001 From: samwaseda Date: Fri, 19 Jul 2024 13:15:59 +0000 Subject: [PATCH 1/2] Use with open --- pyiron_base/project/archiving/export_archive.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyiron_base/project/archiving/export_archive.py b/pyiron_base/project/archiving/export_archive.py index 7580e4862..cea358218 100644 --- a/pyiron_base/project/archiving/export_archive.py +++ b/pyiron_base/project/archiving/export_archive.py @@ -57,10 +57,10 @@ def generate_list_of_directories(df_files, directory_to_transfer, archive_direct def compress_dir(archive_directory): arch_comp_name = archive_directory + ".tar.gz" - tar = tarfile.open(arch_comp_name, "w:gz") - tar.add(os.path.relpath(archive_directory, os.getcwd())) - tar.close() + with tarfile.open(arch_comp_name, "w:gz") as tar: + tar.add(archive_directory) rmtree(archive_directory) + return arch_comp_name def copy_files_to_archive( From 7de65f7d61bdd408862f1094879960a0b0ef7937 Mon Sep 17 00:00:00 2001 From: samwaseda Date: Fri, 19 Jul 2024 13:31:54 +0000 Subject: [PATCH 2/2] restore rel_path --- pyiron_base/project/archiving/export_archive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyiron_base/project/archiving/export_archive.py b/pyiron_base/project/archiving/export_archive.py index 3eb3fb645..a99ead0fa 100644 --- a/pyiron_base/project/archiving/export_archive.py +++ b/pyiron_base/project/archiving/export_archive.py @@ -58,7 +58,7 @@ def generate_list_of_directories(df_files, directory_to_transfer, archive_direct def compress_dir(archive_directory): arch_comp_name = archive_directory + ".tar.gz" with tarfile.open(arch_comp_name, "w:gz") as tar: - tar.add(archive_directory) + tar.add(os.path.relpath(archive_directory, os.getcwd())) rmtree(archive_directory) return arch_comp_name