From 7898ab4ce7e8ce6bc4ae632575c4d83c2969c44f Mon Sep 17 00:00:00 2001 From: Sterling Baldwin Date: Tue, 8 Oct 2019 11:58:00 -0700 Subject: [PATCH 1/2] Fixes directory paths with slash at the end --- bdbag/bdbag_api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bdbag/bdbag_api.py b/bdbag/bdbag_api.py index 640db30..e105ecb 100644 --- a/bdbag/bdbag_api.py +++ b/bdbag/bdbag_api.py @@ -316,6 +316,9 @@ def archive_bag(bag_path, bag_archiver): logger.error("Error while archiving bag: %s", e) raise e + if bag_path[-1] == os.sep: + bag_path = bag_path[:-1] + logger.info("Archiving bag (%s): %s" % (bag_archiver, bag_path)) tarmode = None archive = None From 530c78b3ed17aeb570eb63c026bb9b3c8ff19018 Mon Sep 17 00:00:00 2001 From: Sterling Baldwin Date: Tue, 8 Oct 2019 12:09:04 -0700 Subject: [PATCH 2/2] Adds trailing-slash archive_bag test --- test/test_api.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test_api.py b/test/test_api.py index f6e39d4..acb325a 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -478,6 +478,14 @@ def test_archive_bag_tar(self): self.assertTrue(ospif(archive_file)) except Exception as e: self.fail(get_typed_exception(e)) + + def test_archive_bag_tar_with_trailing_slash(self): + logger.info(self.getTestHeader('archive bag tar format')) + try: + archive_file = bdb.archive_bag(self.test_bag_dir + os.sep, 'tar') + self.assertTrue(ospif(archive_file)) + except Exception as e: + self.fail(get_typed_exception(e)) def test_archive_bag_incomplete_structure(self): logger.info(self.getTestHeader('archive incomplete bag zip format'))