You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@tongwang I added a test case that (I thought) would exercise the problem, but it passes. Can you get it to fail? Also, what do you see as output when you run validate()?
@edsu the issue is that in the test case even you create the bag with "sha1", the tag manifest file is still in md5. It is hardwired to md5:
def _make_tagmanifest_file(tagmanifest_file, bag_dir):
files = [f for f in listdir(bag_dir) if isfile(join(bag_dir, f))]
checksums = []
for f in files:
if f == tagmanifest_file:
continue
fh = open(join(bag_dir, f), 'rb')
m = hashlib.md5()
while True:
bytes = fh.read(16384)
if not bytes:
break
m.update(bytes)
checksums.append((m.hexdigest(), f))
fh.close()
with open(join(bag_dir, tagmanifest_file), 'w') as tagmanifest:
for digest, filename in checksums:
tagmanifest.write('%s %s\n' % (digest, filename))
It does seem wrong that it would always write a tagmanifest-md5.txt even if you have a manifest-sha1.txt ; but why does this make the bag invalid? Can you construct a test case that fails?
Activity
added test for LibraryOfCongress#32, which passes?
edsu commentedon Sep 19, 2014
@tongwang I added a test case that (I thought) would exercise the problem, but it passes. Can you get it to fail? Also, what do you see as output when you run validate()?
tongwang commentedon Sep 19, 2014
@edsu the issue is that in the test case even you create the bag with "sha1", the tag manifest file is still in md5. It is hardwired to md5:
edsu commentedon Sep 19, 2014
Ouch! I thought there were tests for sha1 manifest generation. I'll check.
edsu commentedon Sep 19, 2014
It does seem wrong that it would always write a tagmanifest-md5.txt even if you have a manifest-sha1.txt ; but why does this make the bag invalid? Can you construct a test case that fails?
edsu commentedon Sep 19, 2014
Oh, in your example you probably have a bag created with another tool which has a tagmanifest-sha1.txt that is not being updated?
edsu commentedon Sep 19, 2014
Ok, I've got a test case that is failing now over here.
tongwang commentedon Sep 19, 2014
Yes, the existing tagmanifest-sha1.txt is not updated, which fails validation.
allow non-md5 tagmanifests to be created. fixes LibraryOfCongress#32
edsu commentedon Sep 19, 2014
@tongwang can you give my latest branch a try? https://github.com/edsu/bagit/tree/issue32 I believe I fixed the issue.
tongwang commentedon Sep 19, 2014
@edsu it works great! Thank you for the quick fix.
edsu commentedon Sep 19, 2014
Awesome. I'll send a pull request, maybe you could merge it in (since I no longer work at LC)?