Ignore muted files in Site.needFile

This commit is contained in:
caryoscelus 2023-08-18 16:51:16 +00:00
parent 4153f60258
commit 4d4880a5c8

View file

@ -216,11 +216,21 @@ class SiteStoragePlugin(object):
filter_storage.includeUpdateAll()
return super(SiteStoragePlugin, self).onUpdated(inner_path, file=file)
@PluginManager.registerTo("Site")
class SitePlugin(object):
def needFile(self, inner_path, update=False, blocking=True, peer=None, priority=0):
self.log.debug(f'needFile {inner_path}')
matches = re.findall('/(1[A-Za-z0-9]{26,35})/', inner_path)
for auth_address in matches:
if filter_storage.isMuted(auth_address):
self.log.info(f'Mute match in Site.needFile: {auth_address}, ignoring {inner_path}')
return False
return super(SitePlugin, self).needFile(inner_path, update, blocking, peer, priority)
@PluginManager.registerTo("FileRequest")
class FileRequestPlugin:
def actionUpdate(self, params):
inner_path = params.get('inner_path', '')
self.log.info(f'FileRequest.actionUpdate {inner_path}')
matches = re.findall('/(1[A-Za-z0-9]{26,35})/', inner_path)
for auth_address in matches:
if filter_storage.isMuted(auth_address):