summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Resch <andrewresch@gmail.com>2009-04-23 20:21:01 +0000
committerAndrew Resch <andrewresch@gmail.com>2009-04-23 20:21:01 +0000
commit653097a985057263739a868aab31a9ee57de1c36 (patch)
tree8816eaba796edbe652358ac8ec5608a181ad5a10
parentbf1a0f9aad1b19767d397fd304f020a2f59fc070 (diff)
downloaddeluge-653097a985057263739a868aab31a9ee57de1c36.tar.gz
deluge-653097a985057263739a868aab31a9ee57de1c36.tar.bz2
deluge-653097a985057263739a868aab31a9ee57de1c36.zip
Fix creating torrents in Windows
Fix displaying improper progress when creating torrent
-rw-r--r--ChangeLog2
-rw-r--r--deluge/metafile.py30
2 files changed, 6 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index db66c46bf..b646a13fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,9 +8,11 @@
* Fix displaying IPv6 peers in the Peers tab
* Fix starting the daemon in OS X
* Fix loading improperly created torrents with mismatched encodings
+ * Fix displaying improper progress when creating torrent
==== Windows ====
* Fix freezing in create torrent dialog
+ * Fix creating torrents in Windows
=== Deluge 1.1.6 - (06 April 2009) ===
==== Core ====
diff --git a/deluge/metafile.py b/deluge/metafile.py
index c85af9462..6626a2704 100644
--- a/deluge/metafile.py
+++ b/deluge/metafile.py
@@ -39,30 +39,7 @@ def gmtime():
return time.mktime(time.gmtime())
def get_filesystem_encoding():
- default_encoding = 'utf8'
-
- if os.path.supports_unicode_filenames:
- encoding = None
- else:
- try:
- encoding = sys.getfilesystemencoding()
- except AttributeError:
- log.debug("This version of Python cannot detect filesystem encoding.")
-
-
- if encoding is None:
- encoding = default_encoding
- log.debug("Python failed to detect filesystem encoding. "
- "Assuming '%s' instead.", default_encoding)
- else:
- try:
- 'a1'.decode(encoding)
- except:
- log.debug("Filesystem encoding '%s' is not supported. Using '%s' instead.",
- encoding, default_encoding)
- encoding = default_encoding
-
- return encoding
+ return sys.getfilesystemencoding()
def decode_from_filesystem(path):
encoding = get_filesystem_encoding()
@@ -155,7 +132,8 @@ def makeinfo(path, piece_length, progress, name = None,
for p, f in subs:
totalsize += os.path.getsize(f)
if totalsize >= piece_length:
- num_pieces = totalsize / piece_length
+ import math
+ num_pieces = math.ceil(float(totalsize) / float(piece_length))
else:
num_pieces = 1
@@ -172,13 +150,13 @@ def makeinfo(path, piece_length, progress, name = None,
while pos < size:
a = min(size - pos, piece_length - done)
sh.update(h.read(a))
- piece_count += 1
done += a
pos += a
totalhashed += a
if done == piece_length:
pieces.append(sh.digest())
+ piece_count += 1
done = 0
sh = sha()
progress(piece_count, num_pieces)