diff options
-rw-r--r-- | gemato/recursiveloader.py | 8 | ||||
-rw-r--r-- | tests/test_recursiveloader.py | 27 |
2 files changed, 31 insertions, 4 deletions
diff --git a/gemato/recursiveloader.py b/gemato/recursiveloader.py index 3a4aeb2..e91158b 100644 --- a/gemato/recursiveloader.py +++ b/gemato/recursiveloader.py @@ -686,15 +686,15 @@ class ManifestRecursiveLoader(object): else: # find appropriate Manifest for this directory if dir_manifest is None: - for mpath, relpath, m in (self + for mpath, mrpath, m in (self ._iter_manifests_for_path(fpath)): - dir_manifest = (mpath, relpath, m) + dir_manifest = (mpath, mrpath, m) break else: - mpath, relpath, m = dir_manifest + mpath, mrpath, m = dir_manifest fe = gemato.manifest.ManifestEntryDATA( - os.path.relpath(fpath, relpath), + os.path.relpath(fpath, mrpath), 0, {}) m.entries.append(fe) diff --git a/tests/test_recursiveloader.py b/tests/test_recursiveloader.py index 5631458..e0067c9 100644 --- a/tests/test_recursiveloader.py +++ b/tests/test_recursiveloader.py @@ -1947,3 +1947,30 @@ MANIFEST a/Manifest 0 MD5 d41d8cd98f00b204e9800998ecf8427e self.assertEqual( gemato.cli.main(['gemato', 'verify', self.dir]), 0) + + +class MultipleSubdirectoryFilesTest(TempDirTestCase): + """ + Regression test for adding a directory with multiple stray files. + """ + + DIRS = ['sub'] + FILES = { + 'Manifest': u'', + 'sub/file.a': u'', + 'sub/file.b': u'', + 'sub/file.c': u'', + } + + def test_update_entries_for_directory(self): + m = gemato.recursiveloader.ManifestRecursiveLoader( + os.path.join(self.dir, 'Manifest')) + m.update_entries_for_directory('', hashes=['SHA256', 'SHA512']) + self.assertEqual(m.find_path_entry('sub/file.a').path, + 'sub/file.a') + self.assertEqual(m.find_path_entry('sub/file.b').path, + 'sub/file.b') + self.assertEqual(m.find_path_entry('sub/file.c').path, + 'sub/file.c') + m.save_manifests() + m.assert_directory_verifies() |