summaryrefslogtreecommitdiff
path: root/buildstream
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-12 11:37:17 -0400
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-12 11:37:17 -0400
commit852f7040e5fb7da37120a39a244ddaacd03e14b7 (patch)
tree1434103fbff963b5afd3b7dcb1c9846249702237 /buildstream
parent188091451550953a23ec792df7f0b32336419c65 (diff)
downloadbuildstream-852f7040e5fb7da37120a39a244ddaacd03e14b7.tar.gz
tar.py source plugin: Use utils.sha256sum()
Diffstat (limited to 'buildstream')
-rw-r--r--buildstream/plugins/sources/tar.py10
1 files changed, 1 insertions, 9 deletions
diff --git a/buildstream/plugins/sources/tar.py b/buildstream/plugins/sources/tar.py
index f174c792d..07be703af 100644
--- a/buildstream/plugins/sources/tar.py
+++ b/buildstream/plugins/sources/tar.py
@@ -50,7 +50,6 @@ import os
import urllib.request
import urllib.error
import tarfile
-import hashlib
import tempfile
from buildstream import Source, SourceError, Consistency
@@ -148,7 +147,7 @@ class TarSource(Source):
os.makedirs(self._get_mirror_dir())
# Store by sha256sum
- sha256 = self._sha256sum(local_file)
+ sha256 = utils.sha256sum(local_file)
# Even if the file already exists, move the new file over.
# In case the old file was corrupted somehow.
os.rename(local_file, self._get_mirror_file(sha256))
@@ -165,13 +164,6 @@ class TarSource(Source):
def _get_mirror_file(self, sha=None):
return os.path.join(self._get_mirror_dir(), sha or self.ref)
- def _sha256sum(self, filename):
- h = hashlib.sha256()
- with open(filename, "rb") as f:
- for chunk in iter(lambda: f.read(4096), b""):
- h.update(chunk)
- return h.hexdigest()
-
# Override and translate which filenames to extract
def _extract_members(self, tar, base_dir):
if not base_dir.endswith(os.sep):