Fix displaying im...
Content-type: text/plain

Author: andar

Revision: 5144

Log:
        Fix creating torrents in Windows
Fix displaying improper progress when creating torrent

Diff:
Modified: branches/1.1.0_RC/ChangeLog
===================================================================
--- branches/1.1.0_RC/ChangeLog 2009-04-23 20:18:17 UTC (rev 5143)
+++ branches/1.1.0_RC/ChangeLog 2009-04-23 20:21:01 UTC (rev 5144)
@@ -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 ====

Modified: branches/1.1.0_RC/deluge/metafile.py
===================================================================
--- branches/1.1.0_RC/deluge/metafile.py        2009-04-23 20:18:17 UTC (rev 
5143)
+++ branches/1.1.0_RC/deluge/metafile.py        2009-04-23 20:21:01 UTC (rev 
5144)
@@ -39,31 +39,8 @@
     return time.mktime(time.gmtime())
 
 def get_filesystem_encoding():
-    default_encoding = 'utf8'
+    return sys.getfilesystemencoding()
 
-    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
-
 def decode_from_filesystem(path):
     encoding = get_filesystem_encoding()
     if encoding == None:
@@ -155,7 +132,8 @@
         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 @@
             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)

Modified: trunk/deluge/metafile.py
===================================================================
--- trunk/deluge/metafile.py    2009-04-23 20:18:17 UTC (rev 5143)
+++ trunk/deluge/metafile.py    2009-04-23 20:21:01 UTC (rev 5144)
@@ -39,31 +39,8 @@
     return time.mktime(time.gmtime())
 
 def get_filesystem_encoding():
-    default_encoding = 'utf8'
+    return sys.getfilesystemencoding()
 
-    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
-
 def decode_from_filesystem(path):
     encoding = get_filesystem_encoding()
     if encoding == None:
@@ -155,7 +132,8 @@
         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 @@
             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)



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to