Fix renaming folders on libtorrent 0.16 compiled with unicode support (Windows)

This commit is contained in:
Chase Sterling 2013-02-11 21:26:16 -05:00
parent b08573831e
commit 36d8c5517f
1 changed files with 8 additions and 4 deletions

View File

@ -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))