Move optional files hashfield adding to workermanager for better performance
This commit is contained in:
parent
906f6c65d9
commit
2ab04deded
2 changed files with 6 additions and 9 deletions
|
@ -23,7 +23,6 @@ class ContentManager(object):
|
||||||
self.contents = ContentDbDict(site)
|
self.contents = ContentDbDict(site)
|
||||||
self.hashfield = PeerHashfield()
|
self.hashfield = PeerHashfield()
|
||||||
self.has_optional_files = False
|
self.has_optional_files = False
|
||||||
self.site.onFileDone.append(lambda inner_path: self.addOptionalFile(inner_path))
|
|
||||||
|
|
||||||
def loadContents(self):
|
def loadContents(self):
|
||||||
if len(self.contents) == 0:
|
if len(self.contents) == 0:
|
||||||
|
@ -800,12 +799,6 @@ class ContentManager(object):
|
||||||
self.log.error("File not in content.json: %s" % inner_path)
|
self.log.error("File not in content.json: %s" % inner_path)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def addOptionalFile(self, inner_path):
|
|
||||||
info = self.getFileInfo(inner_path)
|
|
||||||
if info and info["optional"]:
|
|
||||||
self.log.debug("Downloaded optional file, adding to hashfield: %s" % inner_path)
|
|
||||||
self.hashfield.appendHash(info["sha512"])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
def testSign():
|
def testSign():
|
||||||
|
|
|
@ -8,10 +8,11 @@ import gevent
|
||||||
from Worker import Worker
|
from Worker import Worker
|
||||||
from Config import config
|
from Config import config
|
||||||
from util import helper
|
from util import helper
|
||||||
|
from Plugin import PluginManager
|
||||||
import util
|
import util
|
||||||
|
|
||||||
|
@PluginManager.acceptPlugins
|
||||||
class WorkerManager:
|
class WorkerManager(object):
|
||||||
|
|
||||||
def __init__(self, site):
|
def __init__(self, site):
|
||||||
self.site = site
|
self.site = site
|
||||||
|
@ -417,6 +418,9 @@ class WorkerManager:
|
||||||
def doneTask(self, task):
|
def doneTask(self, task):
|
||||||
task["done"] = True
|
task["done"] = True
|
||||||
self.tasks.remove(task) # Remove from queue
|
self.tasks.remove(task) # Remove from queue
|
||||||
|
if task["optional_hash_id"]:
|
||||||
|
self.log.debug("Downloaded optional file, adding to hashfield: %s" % task["inner_path"])
|
||||||
|
self.site.content_manager.hashfield.appendHashId(task["optional_hash_id"])
|
||||||
self.site.onFileDone(task["inner_path"])
|
self.site.onFileDone(task["inner_path"])
|
||||||
task["evt"].set(True)
|
task["evt"].set(True)
|
||||||
if not self.tasks:
|
if not self.tasks:
|
||||||
|
|
Loading…
Reference in a new issue