Lines 834-858
def connect_peer(self, ip, port):
Link Here
|
834 |
def move_storage(self, dest): |
834 |
def move_storage(self, dest): |
835 |
"""Move a torrent's storage location""" |
835 |
"""Move a torrent's storage location""" |
836 |
|
836 |
|
837 |
# Attempt to convert utf8 path to unicode |
837 |
if not os.path.exists(dest): |
838 |
# Note: Inconsistent encoding for 'dest', needs future investigation |
|
|
839 |
try: |
840 |
dest_u = unicode(dest, "utf-8") |
841 |
except TypeError: |
842 |
# String is already unicode |
843 |
dest_u = dest |
844 |
|
845 |
if not os.path.exists(dest_u): |
846 |
try: |
838 |
try: |
847 |
# Try to make the destination path if it doesn't exist |
839 |
# Try to make the destination path if it doesn't exist |
848 |
os.makedirs(dest_u) |
840 |
os.makedirs(dest) |
849 |
except IOError, e: |
841 |
except IOError, e: |
850 |
log.exception(e) |
842 |
log.exception(e) |
851 |
log.error("Could not move storage for torrent %s since %s does not exist and could not create the directory.", self.torrent_id, dest_u) |
843 |
log.error("Could not move storage for torrent %s since %s does not exist and could not create the directory.", self.torrent_id, dest) |
852 |
return False |
844 |
return False |
853 |
try: |
845 |
try: |
854 |
self.handle.move_storage(dest_u) |
846 |
self.handle.move_storage(dest) |
855 |
except: |
847 |
except Exception, e: |
|
|
848 |
log.exception(e) |
856 |
return False |
849 |
return False |
857 |
|
850 |
|
858 |
return True |
851 |
return True |