downloads can be accessed from tasks, start it earlier

This commit is contained in:
j 2016-02-18 12:15:15 +05:30
parent 9dda2f7303
commit 030563c933
2 changed files with 5 additions and 4 deletions

View file

@ -584,8 +584,9 @@ class Item(db.Model):
else: else:
self.added = None self.added = None
self.update() self.update()
if self.id in state.downloads.transfers: if state.downloads:
del state.downloads.transfers[self.id] if self.id in state.downloads.transfers:
del state.downloads.transfers[self.id]
Changelog.record(user, 'removeitem', self.id) Changelog.record(user, 'removeitem', self.id)
class Sort(db.Model): class Sort(db.Model):

View file

@ -17,6 +17,7 @@ from item.icons import IconHandler
import db import db
import node.server import node.server
import oxtornado import oxtornado
import downloads
import settings import settings
import setup import setup
import state import state
@ -148,14 +149,12 @@ def run():
state.cache = Cache(ttl=60) state.cache = Cache(ttl=60)
def start_node(): def start_node():
import downloads
import nodes import nodes
import tor import tor
import bandwidth import bandwidth
state.bandwidth = bandwidth.Bandwidth() state.bandwidth = bandwidth.Bandwidth()
state.tor = tor.Tor() state.tor = tor.Tor()
state.node = node.server.start() state.node = node.server.start()
state.downloads = downloads.Downloads()
state.nodes = nodes.Nodes() state.nodes = nodes.Nodes()
def publish(): def publish():
if not state.tor.is_online(): if not state.tor.is_online():
@ -166,6 +165,7 @@ def run():
state.main.call_later(10, lambda: state.tasks.queue('scanimport')) state.main.call_later(10, lambda: state.tasks.queue('scanimport'))
if not state.update: if not state.update:
state.downloads = downloads.Downloads()
state.tasks = tasks.Tasks() state.tasks = tasks.Tasks()
state.main.add_callback(start_node) state.main.add_callback(start_node)
else: else: