[game-data-packager] 01/03: data: Include size in HashedFile
Simon McVittie
smcv at debian.org
Tue Nov 28 09:56:54 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch master
in repository game-data-packager.
commit c7a62dbe191960fcc0e61d65522e96fad51b58eb
Author: Simon McVittie <smcv at debian.org>
Date: Tue Nov 28 08:40:51 2017 +0000
data: Include size in HashedFile
Signed-off-by: Simon McVittie <smcv at debian.org>
---
game_data_packager/data.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/game_data_packager/data.py b/game_data_packager/data.py
index 4e11990..42bab22 100644
--- a/game_data_packager/data.py
+++ b/game_data_packager/data.py
@@ -45,6 +45,7 @@ class HashedFile:
self._md5 = None
self._sha1 = None
self._sha256 = None
+ self._size = None
self.skip_hash_matching = False
@classmethod
@@ -85,6 +86,7 @@ class HashedFile:
self.md5 = md5.hexdigest()
self.sha1 = sha1.hexdigest()
self.sha256 = sha256.hexdigest()
+ self._size = done
return self
@property
@@ -99,6 +101,12 @@ class HashedFile:
if self.skip_hash_matching or other.skip_hash_matching:
return False
+ if None not in (self.size, other.size):
+ # Don't set matched: the size is only a very weak way to
+ # compare for equality
+ if self.size != other.size:
+ return False
+
if None not in (self.md5, other.md5):
matched = True
if self.md5 != other.md5:
@@ -117,17 +125,21 @@ class HashedFile:
if not matched:
raise ValueError(('Unable to determine whether checksums match:\n' +
'%s has:\n' +
+ ' size: %s\n' +
' md5: %s\n' +
' sha1: %s\n' +
' sha256: %s\n' +
'%s has:\n' +
+ ' size: %s\n' +
' md5: %s\n' +
' sha1: %s\n' +
' sha256: %s\n') % (
+ self.size,
self.name,
self.md5,
self.sha1,
self.sha256,
+ other.size,
other.name,
other.md5,
other.sha1,
@@ -136,6 +148,10 @@ class HashedFile:
return True
@property
+ def size(self):
+ return self._size
+
+ @property
def md5(self):
return self._md5
@md5.setter
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list