Lines 886-912
def connect_peer(self, ip, port):
Link Here
|
886 |
def move_storage(self, dest): |
886 |
def move_storage(self, dest): |
887 |
"""Move a torrent's storage location""" |
887 |
"""Move a torrent's storage location""" |
888 |
|
888 |
|
889 |
# Attempt to convert utf8 path to unicode |
889 |
if not os.path.exists(dest): |
890 |
# Note: Inconsistent encoding for 'dest', needs future investigation |
|
|
891 |
try: |
892 |
dest_u = unicode(dest, "utf-8") |
893 |
except TypeError: |
894 |
# String is already unicode |
895 |
dest_u = dest |
896 |
|
897 |
if not os.path.exists(dest_u): |
898 |
try: |
890 |
try: |
899 |
# Try to make the destination path if it doesn't exist |
891 |
# Try to make the destination path if it doesn't exist |
900 |
os.makedirs(dest_u) |
892 |
os.makedirs(dest) |
901 |
except IOError, e: |
893 |
except IOError, e: |
902 |
log.exception(e) |
894 |
log.exception(e) |
903 |
log.error("Could not move storage for torrent %s since %s does " |
895 |
log.error("Could not move storage for torrent %s since %s does " |
904 |
"not exist and could not create the directory.", |
896 |
"not exist and could not create the directory.", |
905 |
self.torrent_id, dest_u) |
897 |
self.torrent_id, dest) |
906 |
return False |
898 |
return False |
907 |
try: |
899 |
try: |
908 |
self.handle.move_storage(dest_u) |
900 |
self.handle.move_storage(dest) |
909 |
except: |
901 |
except Exception, e: |
|
|
902 |
log.exception(e) |
910 |
return False |
903 |
return False |
911 |
|
904 |
|
912 |
return True |
905 |
return True |