[#2703] [Core] Stop moving files if target files exist

This commit is contained in:
Calum Lind 2015-09-28 19:05:43 +01:00
parent 244ae878c9
commit 560318a5a7
2 changed files with 6 additions and 2 deletions

View File

@ -855,13 +855,16 @@ class Torrent(object):
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)
return False
kwargs = {}
if deluge.common.VersionSplit(lt.version) >= deluge.common.VersionSplit("1.0.0.0"):
kwargs['flags'] = 1 # fail_if_exist
dest_bytes = dest.encode('utf-8')
try:
# libtorrent needs unicode object if wstrings are enabled, utf8 bytestring otherwise
try:
self.handle.move_storage(dest)
self.handle.move_storage(dest, **kwargs)
except TypeError:
self.handle.move_storage(dest_bytes)
self.handle.move_storage(dest_bytes, **kwargs)
except Exception, e:
log.error("Error calling libtorrent move_storage: %s" % e)
return False

View File

@ -1064,6 +1064,7 @@ class TorrentManager(component.Component):
except (RuntimeError, KeyError):
return
log.error("Torrent %s, %s", torrent_id, decode_string(alert.message()))
if torrent_id in self.waiting_on_finish_moving:
self.waiting_on_finish_moving.remove(torrent_id)
torrent.is_finished = True