mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-26 03:09:13 +00:00
Use a more efficient sort to put the torrent state list in queue order
This commit is contained in:
parent
139519d7d1
commit
a7c2e596d9
@ -37,10 +37,10 @@
|
|||||||
"""TorrentManager handles Torrent objects"""
|
"""TorrentManager handles Torrent objects"""
|
||||||
|
|
||||||
import cPickle
|
import cPickle
|
||||||
import os.path
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
|
import operator
|
||||||
|
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
@ -507,16 +507,9 @@ class TorrentManager(component.Component):
|
|||||||
|
|
||||||
# Reorder the state.torrents list to add torrents in the correct queue
|
# Reorder the state.torrents list to add torrents in the correct queue
|
||||||
# order.
|
# order.
|
||||||
ordered_state = []
|
state.torrents.sort(key=operator.attrgetter("queue"))
|
||||||
for torrent_state in state.torrents:
|
|
||||||
for t in ordered_state:
|
|
||||||
if torrent_state.queue < t.queue:
|
|
||||||
ordered_state.insert(ordered_state.index(t), torrent_state)
|
|
||||||
break
|
|
||||||
if torrent_state not in ordered_state:
|
|
||||||
ordered_state.append(torrent_state)
|
|
||||||
|
|
||||||
for torrent_state in ordered_state:
|
for torrent_state in state.torrents:
|
||||||
try:
|
try:
|
||||||
self.add(state=torrent_state, save_state=False)
|
self.add(state=torrent_state, save_state=False)
|
||||||
except AttributeError, e:
|
except AttributeError, e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user