From 0deea7133df90054df5453a2949cad0b0bfd4625 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Mon, 15 Oct 2018 13:03:36 +0200 Subject: [PATCH] Stop downloading bigfile piece if file removed --- plugins/Bigfile/BigfilePlugin.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/Bigfile/BigfilePlugin.py b/plugins/Bigfile/BigfilePlugin.py index d3ac37b1..184c0865 100644 --- a/plugins/Bigfile/BigfilePlugin.py +++ b/plugins/Bigfile/BigfilePlugin.py @@ -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)