Try to find already running task for file before start a new one

This commit is contained in:
shortcutme 2019-12-17 14:30:14 +01:00
parent 31a6e3ee9a
commit af1ac9bce8
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -760,7 +760,13 @@ class Site(object):
# Check and download if file not exist # Check and download if file not exist
def needFile(self, inner_path, update=False, blocking=True, peer=None, priority=0): def needFile(self, inner_path, update=False, blocking=True, peer=None, priority=0):
if self.storage.isFile(inner_path) and not update: # File exist, no need to do anything if self.worker_manager.tasks.findTask(inner_path):
task = self.worker_manager.addTask(inner_path, peer, priority=priority)
if blocking:
return task["evt"].get()
else:
return task["evt"]
elif self.storage.isFile(inner_path) and not update: # File exist, no need to do anything
return True return True
elif not self.isServing(): # Site not serving elif not self.isServing(): # Site not serving
return False return False