diff --git a/plugins/Bigfile/BigfilePlugin.py b/plugins/Bigfile/BigfilePlugin.py index 184c0865..484d2b6d 100644 --- a/plugins/Bigfile/BigfilePlugin.py +++ b/plugins/Bigfile/BigfilePlugin.py @@ -705,6 +705,14 @@ class PeerPlugin(object): class SitePlugin(object): def isFileDownloadAllowed(self, inner_path, file_info): if "piecemap" in file_info: + file_size_mb = file_info["size"] / 1024 / 1024 + if config.bigfile_size_limit and file_size_mb > config.bigfile_size_limit: + self.log.debug( + "Bigfile size %s too large: %sMB > %sMB, skipping..." % + (inner_path, file_size_mb, config.bigfile_size_limit) + ) + return False + file_info = file_info.copy() file_info["size"] = file_info["piece_size"] return super(SitePlugin, self).isFileDownloadAllowed(inner_path, file_info) @@ -754,5 +762,6 @@ class ConfigPlugin(object): def createArguments(self): group = self.parser.add_argument_group("Bigfile plugin") group.add_argument('--autodownload_bigfile_size_limit', help='Also download bigfiles smaller than this limit if help distribute option is checked', default=1, metavar="MB", type=int) + group.add_argument('--bigfile_size_limit', help='Maximum size of downloaded big files', default=False, metavar="MB", type=int) return super(ConfigPlugin, self).createArguments()