From f53e6a5cdf4f345cb005ac34a61fa26704c1d288 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Thu, 2 Nov 2017 09:24:44 +0100 Subject: recursiveloader: Fix updating deeply nested compressed Manifests --- gemato/recursiveloader.py | 6 ++++-- tests/test_recursiveloader.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gemato/recursiveloader.py b/gemato/recursiveloader.py index 0bc00b1..ed7d034 100644 --- a/gemato/recursiveloader.py +++ b/gemato/recursiveloader.py @@ -516,11 +516,13 @@ class ManifestRecursiveLoader(object): if e.tag != 'MANIFEST': continue - if e.path in renamed_manifests: - e.path = renamed_manifests[e.path] fullpath = os.path.join(relpath, e.path) if not force and fullpath not in self.updated_manifests: + assert fullpath not in renamed_manifests continue + if fullpath in renamed_manifests: + fullpath = renamed_manifests[fullpath] + e.path = os.path.relpath(fullpath, relpath) gemato.verify.update_entry_for_path( os.path.join(self.root_directory, fullpath), diff --git a/tests/test_recursiveloader.py b/tests/test_recursiveloader.py index c115763..a5ee83a 100644 --- a/tests/test_recursiveloader.py +++ b/tests/test_recursiveloader.py @@ -590,6 +590,16 @@ OPTIONAL nonstray self.assertNotEqual(m.find_timestamp().ts, datetime.datetime(2017, 1, 1, 1, 1, 1)) + def test_compress_manifests_low_watermark(self): + m = gemato.recursiveloader.ManifestRecursiveLoader( + os.path.join(self.dir, 'Manifest'), + hashes=['SHA256', 'SHA512']) + m.save_manifests(force=True, compress_watermark=0) + self.assertFalse(os.path.exists( + os.path.join(self.dir, 'Manifest'))) + self.assertTrue(os.path.exists( + os.path.join(self.dir, 'Manifest.gz'))) + class MultipleManifestTest(TempDirTestCase): DIRS = ['sub'] -- cgit v1.2.3