Fix errors resulting from #318

When commit ddfc3a8300 ("Run file_data_filter on deleted files")
started calling the file_data_filter plugin method, in order to make
deletion of plugin-renamed files work, the example plugins were not
updated. This commit updates the example plugins to not crash when the
file context is None.

Thanks to @hetas discovering this.

Closes 328
This commit is contained in:
Frej Drejhammar
2024-04-07 15:06:37 +02:00
parent 3de7bcfc18
commit 893d6302b7
2 changed files with 4 additions and 0 deletions

View File

@@ -6,6 +6,8 @@ class Filter():
pass
def file_data_filter(self,file_data):
if file_data['file_ctx'] == None:
return
file_ctx = file_data['file_ctx']
if not file_ctx.isbinary():
file_data['data'] = file_data['data'].replace(b'\r\n', b'\n')

View File

@@ -15,6 +15,8 @@ class Filter:
d = file_data['data']
file_ctx = file_data['file_ctx']
filename = file_data['filename']
if file_ctx == None:
return
filter_cmd = self.filter_contents + [filename, node.hex(file_ctx.filenode()), '1' if file_ctx.isbinary() else '0']
try:
filter_proc = subprocess.Popen(filter_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)