From 36d8c5517ff6c145e450f58df7261a3898fdd2ed Mon Sep 17 00:00:00 2001 From: Chase Sterling Date: Mon, 11 Feb 2013 21:26:16 -0500 Subject: [PATCH] Fix renaming folders on libtorrent 0.16 compiled with unicode support (Windows) --- deluge/core/torrent.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 28bdc0706..6336d7aa8 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -852,10 +852,10 @@ class Torrent(object): def move_storage(self, dest): """Move a torrent's storage location""" try: - dest = unicode(dest, "utf-8") + dest = unicode(dest, "utf-8") except TypeError: - # String is already unicode - pass + # String is already unicode + pass if not os.path.exists(dest): try: @@ -986,7 +986,11 @@ class Torrent(object): if f["path"].startswith(folder): # Keep track of filerenames we're waiting on wait_on_folder[f["index"]] = Deferred().addBoth(on_file_rename_complete, wait_on_folder, f["index"]) - self.handle.rename_file(f["index"], f["path"].replace(folder, new_folder, 1).encode("utf-8")) + new_path = f["path"].replace(folder, new_folder, 1) + try: + self.handle.rename_file(f["index"], new_path) + except TypeError: + self.handle.rename_file(f["index"], new_path.encode("utf-8")) def on_folder_rename_complete(result, torrent, folder, new_folder): component.get("EventManager").emit(TorrentFolderRenamedEvent(torrent.torrent_id, folder, new_folder))