Actually add piece hashes to the database.
authorCameron Dale <camrdale@gmail.com>
Sat, 12 Apr 2008 22:47:29 +0000 (15:47 -0700)
committerCameron Dale <camrdale@gmail.com>
Sat, 12 Apr 2008 22:47:29 +0000 (15:47 -0700)
apt_p2p/CacheManager.py
apt_p2p/db.py

index ccf13c5..a990768 100644 (file)
@@ -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:
index 63cc7e7..569de9a 100644 (file)
@@ -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