r229 - /debtorrent/branches/unique/DebTorrent/BT1/makemetafile.py
camrdale-guest at users.alioth.debian.org
camrdale-guest at users.alioth.debian.org
Mon Aug 13 19:36:36 UTC 2007
Author: camrdale-guest
Date: Mon Aug 13 19:36:36 2007
New Revision: 229
URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=229
Log:
Fix bug that didn't add empty file to end of torrent if there were empty pieces there.
btmakemetafile works with gzipped files now.
Modified:
debtorrent/branches/unique/DebTorrent/BT1/makemetafile.py
Modified: debtorrent/branches/unique/DebTorrent/BT1/makemetafile.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/branches/unique/DebTorrent/BT1/makemetafile.py?rev=229&op=diff
==============================================================================
--- debtorrent/branches/unique/DebTorrent/BT1/makemetafile.py (original)
+++ debtorrent/branches/unique/DebTorrent/BT1/makemetafile.py Mon Aug 13 19:36:36 2007
@@ -29,7 +29,7 @@
from time import time
from traceback import print_exc
from DebTorrent.zurllib import urlopen
-from gzip import GzipFile
+import gzip
from StringIO import StringIO
from re import subn
import binascii, logging
@@ -308,7 +308,10 @@
if pieces_file:
try:
- f = open(pieces_file)
+ if torrent_file.endswith('.gz'):
+ f = gzip.open(pieces_file)
+ else:
+ f = open(pieces_file)
except:
logger.exception('sub-pieces file not found: '+pieces_file)
return {}
@@ -401,7 +404,10 @@
if torrent_file:
try:
- f = open(torrent_file)
+ if torrent_file.endswith('.gz'):
+ f = gzip.open(torrent_file)
+ else:
+ f = open(torrent_file)
except:
logger.exception('torrent ordering file not found: '+torrent_file)
return (pieces, headers)
@@ -520,6 +526,9 @@
lengths[piece_ordering[cur_piece]]
fs_list.append(fs[piece_ordering[cur_piece]])
cur_piece = cur_piece + len_pieces
+ if num_pieces > cur_piece:
+ fs_list.append({'length': 0, 'path': []})
+ cur_piece = num_pieces
else:
pieces_list = []
lengths_list = []
@@ -681,7 +690,10 @@
ordering_all_headers = {}
file = abspath(file)
- f = open(file)
+ if file.endswith('.gz'):
+ f = gzip.open(file)
+ else:
+ f = open(file)
(info, info_all) = getpieces(f, encoding, progress, separate_all, sub_pieces,
piece_ordering, piece_ordering_all,
int(ordering_headers.get('NextPiece', 0)),
More information about the Debtorrent-commits
mailing list