When the bag._load_manifests function loops looking for tagmanifest- and manifest- files to determine the checksum algorithms currently in use, it calls self.algorithms.append(alg), which generates duplicate algorithm identifier list items in self.algorithms; once for the tagmanifest- files and then again for the manifest- files.
Additionally, the more calls to _load_manifests that are made on a given bag instance, the more the list grows. Calling bag.save causes this list to grow for every invocation, since at the end of the function self._load_manifests is called in order to reload the modified manifests. This also causes the bag.save function to invoke _make_tagmanifest_file unnecessarily for every duplicate list entry. You can see this behavior in action during the unit test function test_save_manifests.
The one-liner fix in this PR just checks for the existence of alg in self.algorithms before performing the append. Alternatively, I suppose self.algorithms could just be converted to (or wrapped with) a set, which is probably more pythonic.
Coverage increased (+0.05%) to 83.211% when pulling deea5960ef4b7b8bfbea6e8858b1d5316bb4569b on mikedarcy:master into 1aa5090fa6124a1cd0c675fe670eb0ee38fb151b on LibraryOfCongress:master.
Coverage increased (+0.05%) to 83.211% when pulling deea5960ef4b7b8bfbea6e8858b1d5316bb4569b on mikedarcy:master into 1aa5090fa6124a1cd0c675fe670eb0ee38fb151b on LibraryOfCongress:master.
Coverage increased (+0.05%) to 83.211% when pulling deea5960ef4b7b8bfbea6e8858b1d5316bb4569b on mikedarcy:master into 1aa5090fa6124a1cd0c675fe670eb0ee38fb151b on LibraryOfCongress:master.
Coverage increased (+0.05%) to 83.211% when pulling deea5960ef4b7b8bfbea6e8858b1d5316bb4569b on mikedarcy:master into 1aa5090fa6124a1cd0c675fe670eb0ee38fb151b on LibraryOfCongress:master.
When the
bag._load_manifests
function loops looking fortagmanifest-
andmanifest-
files to determine the checksum algorithms currently in use, it callsself.algorithms.append(alg)
, which generates duplicate algorithm identifier list items inself.algorithms
; once for thetagmanifest-
files and then again for themanifest-
files.Additionally, the more calls to
_load_manifests
that are made on a given bag instance, the more the list grows. Callingbag.save
causes this list to grow for every invocation, since at the end of the functionself._load_manifests
is called in order to reload the modified manifests. This also causes thebag.save
function to invoke_make_tagmanifest_file
unnecessarily for every duplicate list entry. You can see this behavior in action during the unit test functiontest_save_manifests
.The one-liner fix in this PR just checks for the existence of
alg
inself.algorithms
before performing the append. Alternatively, I supposeself.algorithms
could just be converted to (or wrapped with) aset
, which is probably more pythonic.