Skip to content

Commit

Permalink
core: Check for same path before attempting to move completed torrents
Browse files Browse the repository at this point in the history
  • Loading branch information
ratanakvlun committed Jan 27, 2014
1 parent 6f5dfad commit 9d0828a
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions labelplus/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,11 @@ def on_torrent_finished(self, alert):

if torrent_id in self._mappings:
log.debug("[%s] Labeled torrent %s finished", PLUGIN_NAME, torrent_id)
label_id = self._mappings[torrent_id]
torrent = self._torrents[torrent_id]

path = torrent.get_status(["save_path"])["save_path"]
if path != self._labels[label_id]["data"]["move_data_completed_path"]:
if self._prefs["options"]["move_after_recheck"]:
# Just finished recheck or move by Deluge hasn't completed.
# Move Tools will deal with either of these situations.
self._do_move_completed(label_id, [torrent_id])
if self._prefs["options"]["move_after_recheck"]:
# Try to move in case this alert was from a recheck
label_id = self._mappings[torrent_id]
self._do_move_completed(label_id, [torrent_id])


def _initialize(self):
Expand Down Expand Up @@ -982,15 +978,27 @@ def _do_move_completed(self, label_id, torrent_list):

if label_id in self._labels:
options = self._labels[label_id]["data"]

if not options["download_settings"] or \
not options["move_data_completed"]:
return

dest_path = options["move_data_completed_path"]
else:
label_id = None

if not label_id or (
options["download_settings"] and options["move_data_completed"]):
try:
component.get("CorePlugin.MoveTools").move_completed(torrent_list)
except KeyError:
pass
dest_path = self._get_default_save_path()

move_list = []
for tid in torrent_list:
torrent = self._torrents.get(tid)
if torrent:
path = torrent.get_status(["save_path"])["save_path"]
if path != dest_path:
move_list.append(tid)

try:
component.get("CorePlugin.MoveTools").move_completed(move_list)
except KeyError:
pass


def _get_default_save_path(self):
Expand Down

0 comments on commit 9d0828a

Please sign in to comment.