From: Cameron Dale Date: Sat, 12 Apr 2008 22:47:29 +0000 (-0700) Subject: Actually add piece hashes to the database. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d989fd732226930085c417a452dab4a5353fead6;p=quix0rs-apt-p2p.git Actually add piece hashes to the database. --- diff --git a/apt_p2p/CacheManager.py b/apt_p2p/CacheManager.py index ccf13c5..a990768 100644 --- a/apt_p2p/CacheManager.py +++ b/apt_p2p/CacheManager.py @@ -307,7 +307,8 @@ class CacheManager: url = 'http:/' + file.path[len(self.cache_dir.path):] # Store the hashed file in the database - new_hash = self.db.storeFile(file, result.digest()) + new_hash = self.db.storeFile(file, result.digest(), + ''.join(result.pieceDigests())) # Tell the main program to handle the new cache file df = self.manager.new_cached_file(file, result, new_hash, url, True) @@ -402,7 +403,8 @@ class CacheManager: else: log.msg('Hashed file to %s: %s' % (hash.hexdigest(), url)) - new_hash = self.db.storeFile(destFile, hash.digest()) + new_hash = self.db.storeFile(destFile, hash.digest(), + ''.join(hash.pieceDigests())) log.msg('now avaliable: %s' % (url)) if self.manager: diff --git a/apt_p2p/db.py b/apt_p2p/db.py index 63cc7e7..569de9a 100644 --- a/apt_p2p/db.py +++ b/apt_p2p/db.py @@ -5,7 +5,7 @@ from datetime import datetime, timedelta from pysqlite2 import dbapi2 as sqlite from binascii import a2b_base64, b2a_base64 from time import sleep -import os +import os, sha from twisted.python.filepath import FilePath from twisted.trial import unittest