[diffoscope] 01/01: comparators.debian: No need to keep .buildinfo file descriptor open.
Chris Lamb
chris at chris-lamb.co.uk
Thu Dec 22 10:06:43 CET 2016
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository diffoscope.
commit 120d0cfff9bbbbb5a570f2e3f92736e404d7c4e1
Author: Chris Lamb <lamby at debian.org>
Date: Wed Dec 21 22:13:40 2016 +0000
comparators.debian: No need to keep .buildinfo file descriptor open.
Signed-off-by: Chris Lamb <lamby at debian.org>
---
diffoscope/comparators/debian.py | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/diffoscope/comparators/debian.py b/diffoscope/comparators/debian.py
index a145992..fa02064 100644
--- a/diffoscope/comparators/debian.py
+++ b/diffoscope/comparators/debian.py
@@ -192,18 +192,18 @@ class DotBuildinfoFile(DebControlFile):
with open(file.path, 'rb') as f:
# We can parse .buildinfo just like .dsc
buildinfo = Dsc(f)
- if not 'Checksums-Sha256' in buildinfo:
+ if not 'Checksums-Sha256' in buildinfo:
+ return False
+ for d in buildinfo.get('Checksums-Sha256'):
+ sha256 = hashlib.sha256()
+ # XXX: this will not work for containers
+ in_buildinfo_path = os.path.join(os.path.dirname(file.path), d['Name'])
+ if not os.path.exists(in_buildinfo_path):
return False
- for d in buildinfo.get('Checksums-Sha256'):
- sha256 = hashlib.sha256()
- # XXX: this will not work for containers
- in_buildinfo_path = os.path.join(os.path.dirname(file.path), d['Name'])
- if not os.path.exists(in_buildinfo_path):
- return False
- with open(in_buildinfo_path, 'rb') as f:
- for buf in iter(functools.partial(f.read, 32768), b''):
- sha256.update(buf)
- if sha256.hexdigest() != d['sha256']:
- return False
- file._deb822 = buildinfo
+ with open(in_buildinfo_path, 'rb') as f:
+ for buf in iter(functools.partial(f.read, 32768), b''):
+ sha256.update(buf)
+ if sha256.hexdigest() != d['sha256']:
+ return False
+ file._deb822 = buildinfo
return True
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list