]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
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 ccf13c5e308f9d105e29e003a6f43fc9019171db..a990768dfc3d7f7d906ace58b67f53f303bef1b8 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 63cc7e72cbc8f783030afe593c8464b708433f14..569de9a38d3c45f0cb1fc4a20d4dfbb97a3f2277 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