From d989fd732226930085c417a452dab4a5353fead6 Mon Sep 17 00:00:00 2001 From: Cameron Dale Date: Sat, 12 Apr 2008 15:47:29 -0700 Subject: [PATCH] Actually add piece hashes to the database. --- apt_p2p/CacheManager.py | 6 ++++-- apt_p2p/db.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) 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 -- 2.39.5