Save the files downloaded from peers in a peers subdirectory.
authorCameron Dale <camrdale@gmail.com>
Wed, 16 Apr 2008 17:10:33 +0000 (10:10 -0700)
committerCameron Dale <camrdale@gmail.com>
Wed, 16 Apr 2008 17:10:33 +0000 (10:10 -0700)
apt_p2p/HTTPServer.py
apt_p2p/apt_p2p.py

index 87e235f729fea40674086ef826975c12f88ef5c4..b5dec02c36e1a8f1c7f428571f7a2e74c5a80d11 100644 (file)
@@ -393,7 +393,7 @@ if __name__ == '__builtin__':
                 return [{'pieces': 'abcdefghij0123456789\xca\xec\xb8\x0c\x00\xe7\x07\xf8~])\x8f\x9d\xe5_B\xff\x1a\xc4!'}]
             return [{'path': FilePath(os.path.expanduser('~/school/optout'))}]
     
-    t = TopLevel(FilePath(os.path.expanduser('~')), DB(), None, 0)
+    t = TopLevel(FilePath(os.path.expanduser('~')), DB(), None)
     factory = t.getHTTPFactory()
     
     # Standard twisted application Boilerplate
index f88fd791a184fde37646501ea2fb941eb17e70fb..4200f6299b78377593ce17cd6ad7b6973de7578e 100644 (file)
@@ -6,7 +6,7 @@
 @var TORRENT_PIECES: the maximum number of pieces to store as a separate entry
     in the DHT
 @var download_dir: the name of the directory to use for downloaded files
-
+@var peer_dir: the name of the directory to use for peer downloads
 """
 
 from binascii import b2a_hex
@@ -34,6 +34,7 @@ DHT_PIECES = 4
 TORRENT_PIECES = 70
 
 download_dir = 'cache'
+peer_dir = 'peers'
 
 class AptP2P:
     """The main code object that does all of the work.
@@ -77,6 +78,8 @@ class AptP2P:
         self.cache_dir = FilePath(config.get('DEFAULT', 'CACHE_DIR'))
         if not self.cache_dir.child(download_dir).exists():
             self.cache_dir.child(download_dir).makedirs()
+        if not self.cache_dir.child(peer_dir).exists():
+            self.cache_dir.child(peer_dir).makedirs()
         self.db = DB(self.cache_dir.child('apt-p2p.db'))
         self.dht = dhtClass()
         self.dht.loadConfig(config, config.get('DEFAULT', 'DHT'))
@@ -84,7 +87,7 @@ class AptP2P:
         self.stats = StatsLogger(self.db)
         self.http_server = TopLevel(self.cache_dir.child(download_dir), self.db, self)
         self.getHTTPFactory = self.http_server.getHTTPFactory
-        self.peers = PeerManager(self.cache_dir, self.dht, self.stats)
+        self.peers = PeerManager(self.cache_dir.child(peer_dir), self.dht, self.stats)
         self.mirrors = MirrorManager(self.cache_dir)
         self.cache = CacheManager(self.cache_dir.child(download_dir), self.db, self)
         self.my_contact = None