From bcd5b2c458dfdebab82e4934d30f2800e573ee37 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 10 Mar 2008 01:46:23 +0000 Subject: [PATCH] When loading state, add torrents with .fastresume files first to avoid waiting for torrents to be checked. --- deluge/core/torrentmanager.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 66f08333c..56a96093b 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -450,8 +450,19 @@ class TorrentManager(component.Component): # First lets clear the queue and make it the correct length.. This will # help with inserting values at the right position. self.queue.set_size(len(state.torrents)) - + + # Reorder the state.torrents list to add torrents with .fastresume files + # first. + fr_first = [] for torrent_state in state.torrents: + if os.path.exists(os.path.join( + self.config["torrentfiles_location"], + torrent_state.filename, ".fastresume")): + fr_first.insert(0, torrent_state) + else: + fr_first.append(torrent_state) + + for torrent_state in fr_first: try: options = { "compact_allocation": torrent_state.compact,