mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 11:35:49 +00:00
Fix creating torrents in Windows
Fix displaying improper progress when creating torrent
This commit is contained in:
parent
bf1a0f9aad
commit
653097a985
2 changed files with 6 additions and 26 deletions
|
@ -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 ====
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue