Support limiting maximum bigfile size
This commit is contained in:
parent
538de08c07
commit
56221ebc95
1 changed files with 9 additions and 0 deletions
|
@ -705,6 +705,14 @@ class PeerPlugin(object):
|
||||||
class SitePlugin(object):
|
class SitePlugin(object):
|
||||||
def isFileDownloadAllowed(self, inner_path, file_info):
|
def isFileDownloadAllowed(self, inner_path, file_info):
|
||||||
if "piecemap" in 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 = file_info.copy()
|
||||||
file_info["size"] = file_info["piece_size"]
|
file_info["size"] = file_info["piece_size"]
|
||||||
return super(SitePlugin, self).isFileDownloadAllowed(inner_path, file_info)
|
return super(SitePlugin, self).isFileDownloadAllowed(inner_path, file_info)
|
||||||
|
@ -754,5 +762,6 @@ class ConfigPlugin(object):
|
||||||
def createArguments(self):
|
def createArguments(self):
|
||||||
group = self.parser.add_argument_group("Bigfile plugin")
|
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('--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()
|
return super(ConfigPlugin, self).createArguments()
|
||||||
|
|
Loading…
Reference in a new issue