Stop downloading bigfile piece if file removed

This commit is contained in:
shortcutme 2018-10-15 13:03:36 +02:00
parent 1eaa8afc5f
commit 0deea7133d
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -371,6 +371,7 @@ class ContentManagerPlugin(object):
for key in self.site.bad_files.keys():
if key.startswith(inner_path + "|"):
del self.site.bad_files[key]
self.site.worker_manager.removeSolvedFileTasks()
return super(ContentManagerPlugin, self).optionalRemoved(inner_path, hash_id, size)
@ -717,8 +718,11 @@ class SitePlugin(object):
def needFile(self, inner_path, *args, **kwargs):
if inner_path.endswith("|all"):
@util.Pooled(20)
def pooledNeedBigfile(*args, **kwargs):
return self.needFile(*args, **kwargs)
def pooledNeedBigfile(inner_path, *args, **kwargs):
if inner_path not in self.bad_files:
self.log.debug("Cancelled piece, skipping %s" % inner_path)
return False
return self.needFile(inner_path, *args, **kwargs)
inner_path = inner_path.replace("|all", "")
file_info = self.needFileInfo(inner_path)
@ -735,7 +739,9 @@ class SitePlugin(object):
piece_from = piece_i * piece_size
piece_to = min(file_size, piece_from + piece_size)
if not piecefield or not piecefield[piece_i]:
res = pooledNeedBigfile("%s|%s-%s" % (inner_path, piece_from, piece_to), blocking=False)
inner_path_piece = "%s|%s-%s" % (inner_path, piece_from, piece_to)
self.bad_files[inner_path_piece] = self.bad_files.get(inner_path_piece, 1)
res = pooledNeedBigfile(inner_path_piece, blocking=False)
if res is not True and res is not False:
file_threads.append(res)
gevent.joinall(file_threads)