aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2019-05-16 20:21:17 -0300
committerSilvio Rhatto <rhatto@riseup.net>2019-05-16 20:21:17 -0300
commitfa895239d52468a60c2e8a68159b1a575ce77264 (patch)
tree740468a3397e0c463e0bf9de0ded76e9e0f6a469
parent5b6309b8bce616ef2b4746166addfbf40ebe3202 (diff)
downloadckandumper-fa895239d52468a60c2e8a68159b1a575ce77264.tar.gz
ckandumper-fa895239d52468a60c2e8a68159b1a575ce77264.tar.bz2
Calculate hash using a subprocess to avoid memory consumption
-rwxr-xr-xckandumper17
1 files changed, 11 insertions, 6 deletions
diff --git a/ckandumper b/ckandumper
index 55cd13a..a11bb24 100755
--- a/ckandumper
+++ b/ckandumper
@@ -95,12 +95,17 @@ class DownloadMultiple:
output.write(str(datetime.datetime.now()) + '\n')
output.close()
- # File might be too big, so we're not computing it's hash here
- #if os.path.exists(local_filename):
- # content = open(local_filename, 'rb')
- # output = open(local_filename + '.sha256', 'w')
- # output.write(sha256(content.read()).hexdigest() + ' ' + os.path.basename(local_filename) + '\n')
- # output.close()
+ if os.path.exists(local_filename):
+ # File might be too big, so we're not computing it's inside the script
+ #content = open(local_filename, 'rb')
+ #output = open(local_filename + '.sha256', 'w')
+ #output.write(sha256(content.read()).hexdigest() + ' ' + os.path.basename(local_filename) + '\n')
+ #output.close()
+ hasher = 'cd ' + os.path.dirname(local_filename) + '&& /usr/bin/sha256sum '
+ hasher += os.path.basename(local_filename) + ' > ' + os.path.basename(local_filename) + '.sha256'
+ hash = await asyncio.create_subprocess_shell(hasher,
+ stdout=asyncio.subprocess.PIPE,
+ stderr=asyncio.subprocess.PIPE)
if not str(proc.returncode) in self.globalstats['exitstatus']:
self.globalstats['exitstatus'][str(proc.returncode)] = []